I want use "splits" by "abi", but only for release build. Is this possible? I try use ext variable and variable by "def" also which is set to false by default. This variable is set to true in buildTypes for releaseWithLog (and release).
But I don't know how Gradle work, because when I add writeln() with test message to "debug", "releaseWithLog" and "release" and run build, all messages are in output, so this confirms me that variable "splitsEnabled" is set to true though I build for debug - and I expect value "false" for debug (and not using splits for debug therefore).
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
ext {
splitsEnabled = false
}
defaultConfig {
...
}
buildTypes {
debug {
...
}
releaseWithLog {
...
splitsEnabled = true
}
release.initWith(releaseWithLog)
release {
...
}
}
...
splits {
abi {
println(splitsEnabled)
enable splitsEnabled
reset()
include 'x86', 'armeabi-v7a', 'armeabi'
exclude 'x86_64', 'mips64', 'arm64-v8a', 'mips'
universalApk true
}
}
...
This is Expert Verified AnswerGradle is an open source, progressive general purpose build management system. It is configured on ANT, Maven, and lvy repositories. It supports Groovy based Domain Specific Language (DSL) over XML.
gradle files in an Android Studio project?
One bit of a downside is that it takes roughly 3 minutes to re-sync when we "Import Gradle Project".
BuildConfig is a class containing static constants that is included in every Android application. BuildConfig includes some default fields such as DEBUG and FLAVOR but you can also add custom values via build. gradle .
You can solve this easily with a command line argument to Gradle, or the "Script parameters:" field for a Gradle task in Android Studio. I used -P to define 'dbgBld' symbol and used it for debug builds, e.g.:
gradle -PdbgBld installDebug
My build.gradle file has the following splits command:
splits {
abi {
enable !project.hasProperty('dbgBld')
reset()
include 'armeabi', 'armeabi-v7a', 'x86', 'mips'
universalApk true
}
}
Now to build release I use:
gradle assembleRelease
The 'dbgBld' symbol is not defined, so the splits enable field resolves to true and I get 5 APK files. When building for debugging, the -PdbgBld is already saved in my Android Studio configuration and I get only one "fat" APK for debugging, which results in much faster debug builds.
Greg
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