I am using an image carousel library that I snagged off of github, but there are a few things I would like to change in the code. I have imported it using the compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+' command. Is that code available for me to edit somehow? Or is it downloaded from github every time I run my code?
Asked
Active
Viewed 1.9k times
3 Answers
25
For this you need to import it as lib and modify as you like:
To import the library to Android Studio, there are two methods that can work.
Method 1:
- Open your project in Android Studio
- Download the library (using Git, or a zip archive to unzip)
- Create a folder "subProject" in your project
- Copy and paste the FreemiumLibrary folder to your subProject folder
- On the root of your project directory create/modify the settings.gradle file. It should contain something like the following:
include 'MyApp', ':subProject:FreemiumLibrary'
- gradle clean & build/close the project and reopen/re-import it.
- Edit your project's build.gradle to add this in the "dependencies" section:
dependencies {
//...
compile project(':subProject:FreemiumLibrary')
}
- Edit your App Activities to extend AdsFragmentActivity instead of Activity.
- Edit the library if you want to use it with ActionBarCompat
Method 2:
- Open your project in Android Studio
- Download the library (using Git, or a zip archive to unzip)
- Go to File > New > Import-Module and import the library as a module
- Right-click your app in project view and select "Open Module Settings"
- Click the "Dependencies" tab and then the '+' button
- Select "Module Dependency"
- Select "Freemium Library" (not Freemium Library Project)
- Modify your App Activities to extend AdsFragmentActivity instead of Activity.
- Modify the library if you want to use it with ActionBarCompat
Shailendra Madda
- 19,210
- 15
- 86
- 129
-
method 1 worked for me, thanks a lot! Only issue I ran into was that the lib I was adding as module had an external .gradle file imported which needed to be removed in order to build successfully – batman Aug 22 '18 at 06:51
-
Glad it helped you. Happy coding :) – Shailendra Madda Aug 22 '18 at 11:52
-
Is there a easy way to update the library afterwards using git? – Merthan Erdem Jan 13 '20 at 20:29
-
1@MerthanE No idea, please explore and post it as a new answer here if it is easier than this. It may help someone. – Shailendra Madda Jan 14 '20 at 11:09
-
this feature has a bug in android studio arctic fox. For solving this issue you can use this answer https://stackoverflow.com/a/68868869/9474700. – behrad Dec 11 '21 at 14:58
3
I solved this way. Fork library project. Then clone it (In Android Studio, File -> New -> Project from Version Control -> put the link of your repository that you forked and open it). Edit it and commit it to your master branch. Then push it to your master branch. And finally find snapshot version of that library. For example if you use JitPack. Go to jitpack.io website and search for your repository (forked version with your username). And there go to commits section and get latest version that you committed. And use that library dependency in your project instead of original repo.
N Droidev
- 816
- 8
- 17
-
I am happy that it worked for you. I searched a lot to find this way. And actually I found this solution by myself. You must change version code and name in gradle.build file too. – N Droidev Nov 25 '20 at 18:41
-
1