I am using Android Studio and have a several apps that rely on the same code. I moved shared code to a separate library in order to include it in my apps.
The library project (MyLib) that I created for this purpose requires a jar-file to compile, so I added it to project's libs directory.
My build.gradle
of MyLib main module looks like this:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.android"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
}
dependencies {
compile files('./libs/external-java-lib.jar')
}
When I build the project, gradle generates a jar-file that contains external-java-lib.jar
.
I want my Android application projects to provide "external-java-lib.jar", not the MyLib. Because in my apps I may use different versions of external-java-lib.jar
.
How do I configure Gradle to exclude external-java-lib.jar
from the build of my library project?
I couldn't find the answer to my question on the net, so I have a feeling that the thing I want is a piece of bad design. What else can I do?
Thank you in advance.