I have a debug build and a release build of an android application however I need different dependencies for each, is this possible in Android Studio?
I have the section:
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
}
}
and a section for the dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'joda-time:joda-time:2.7'
compile 'org.joda:joda-convert:1.4'
}
I want to remove the joda-convert dependancy if I am using the debug build as it results in "duplicate files in packaging of APK" error.
Any help greatly appreciated?
The Gradle build system in Android Studio makes it easy to include external binaries or other library modules to your build as dependencies. The dependencies can be located on your machine or in a remote repository, and any transitive dependencies they declare are automatically included as well.
gradle for one project? Yes. You can have multiple build files in one project.
This isn't necessary. The order inside the dependencies { } block is preserved. You are kind of right. Dependency ordering is preserved, but for example all compile dependencies will be before testCompile dependencies no matter of how you order them.
By default, the project-level Gradle file uses buildscript to define the Gradle repositories and dependencies. This allows different projects to use different Gradle versions.
From the Android gradle documentation:
The
compile
configuration is used to compile the main application. Everything in it is added to the compilation classpath and also packaged in the final APK. There are other possible configurations to add dependencies to:
compile
: main applicationandroidTestCompile
: test applicationdebugCompile
: debug Build TypereleaseCompile
: release Build Type.
you can use
releaseCompile 'org.joda:joda-convert:1.4'
then joda-convert is only used for release
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With