build: split APKs by ABI to optimize size

pull/1978/head
Integral 2 months ago
parent 4b2611e892
commit 7a242f2f7e
No known key found for this signature in database
GPG Key ID: 06313911057DD5A8

@ -1,5 +1,6 @@
import java.util.Properties
import java.io.FileInputStream
import com.android.build.api.variant.FilterConfiguration.FilterType.*
plugins {
id("com.android.application")
@ -87,3 +88,22 @@ android {
flutter {
source = "../.."
}
// From https://developer.android.com/build/configure-apk-splits#configure-APK-versions
//
// The following code creates a mapping that assigns a unique numeric value for each ABI
// and overrides the output version code.
val abiCodes = mapOf("x86_64" to 1, "armeabi-v7a" to 2, "arm64-v8a" to 3)
androidComponents {
onVariants { variant ->
variant.outputs.forEach { output ->
val name = output.filters.find { it.filterType == ABI }?.identifier
val baseAbiCode = abiCodes[name]
if (baseAbiCode != null) {
output.versionCode.set(baseAbiCode + (output.versionCode.get() ?: 0) * 10)
}
}
}
}

Loading…
Cancel
Save