I'm developing an android app, in which I recently migrated from Eclipse to Android Studio and Gradle.
In my projected I created 5 UI Libs, and added them as modules in my project, libs I have created are pushed on my github account (publicly).
In eclipse when you add external dependency for a project marked as lib, when you update the external project's code then you clean your build, your project get these updates, but in Gradle I noticed that it creates Physical Copies, completely independent from their sources, my question is how can I change only external libs and have my project updated.
here's a snipped from my gradle's config:
dependencies {
// Libraries
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.0.89'
.
.
.
compile 'com.squareup.picasso:picasso:2.4.0'
// Projects
compile project(':com.shehabic.helpicon')
.
.
}
How to actually use external libraries
I've read that is not recommended but it is practical for debugging:
File > Project Structure... > PLUS sign to add module
"Create New Module" dialogs:
Back at "Project Structure" dialog:
That does create a copy of your package inside your android project but it also generates all necessary information and files, and you can always get rid of the copy or leave it alone.
Your module have been added to the settings.gradle file:
A build.gradle file for your module have been created:
And the dependency has been added to the build.gradle of your ':app':
configurations.maybeCreate("default") artifacts.add("default", file('X:\Java\Applications\YourApplication\dist\package.jar'))
Wherever you edit your package, just "Clean & Build" it. Whenever you want your app to reflect that "update" in the package from outside your android project, just sync. When you are done debugging, you can remove the module, the dependency and the old copy, and add the last build of your package as a copy.
You must not add the external library as a module. It will make copy of it under your project folder.
What you have to do is:
1) Delete the library folder in your current project. 2) Open the 'seeting.gradle' file and add these:
2) In your 'build.gradle' file add dependency as:
3) Sync the project and you are done.
Do NOT add a module using Studio's "Open Module Settings".
Just add the full path of your library's AAR file in your child app's build gradle:
implementation files('/workspace/AndroidAppsBase/base_app/build/outputs/aar/base_app-debug.aar')
When you make changes to your library project and rebuild the project, a new .aar file will be created. To reflect the change in your child project just rebuild it.