During development most of the time you do not need split apk, but doesn't work settings like bellow.
buildType {
debug {
splits {
abi {
println ("split settings for debug.")
enable false
}
}
}
release {
splits {
abi {
println ("split settings for release.")
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
}
}
This is because the setting process is executed sequentially.
./gradlew assembleDebug
> ...
> split settings for debug.
> split settings for release.
> ...
Solution 1
You can access the gradle task name on gradle scripts. Control the splits by the task name as follows.
android {
splits {
abi {
enable gradle.startParameter.taskNames.contains("assembleRelease")
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
}
Solution 2
You can pass parameters to gradle script.
android {
splits {
abi {
enable project.hasProperty("enabledSplitApks")
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
}
Control split apk as needed.
./gradlew assembleDebug -PenabledSplitApks
It saves build time by omitting extra processing 😄
Top comments (0)