Reputation: 1034
In my Android Studio project, I've added a java module that produces a JAR file which is used by the main module. I understand that Gradle rebuilds all modules on each compile process, but it is clear that it is not needed for java modules if there is no changes since the last build.
So I want to prevent gradle from building my jar file if there is no code changes in the java module, I cannot find such option
Any help is appreciated.
Upvotes: 2
Views: 910
Reputation: 39846
there're two steps to achieve what u want:
so you add dexOptions
inside the android
bracket
android {
dexOptions {
preDexLibraries true
}
}
minSdkVersion 21
, that way the system will build as a multi-dex application so it won't need to merge your dexed library into the APK.There's a whole section on the dev page about it https://developer.android.com/studio/build/multidex.html#dev-build, but what you want to do is add productFlavors
inside the android
bracket
android {
productFlavors {
// Define separate dev and prod product flavors.
dev {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion YOUR_APP_MINIMUM_HERE
}
}
}
Upvotes: 2