Created
February 29, 2020 03:23
-
-
Save ChaosPower/0fa9545c3ff65f80350fa7ff9b571339 to your computer and use it in GitHub Desktop.
Android ABI Split
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
splits { | |
abi { | |
enable true | |
reset() | |
include 'x86', 'armeabi-v7a', 'armeabi', 'arm64-v8a', 'x86_64' | |
universalApk false | |
} | |
} | |
ext.abiCodes = ['armeabi-v7a': 1, x86: 2, armeabi: 3, 'arm64-v8a': 4, 'x86_64': 5] | |
import com.android.build.OutputFile | |
android.applicationVariants.all { variant -> | |
// Assigns a different version code for each output APK | |
// other than the universal APK. | |
variant.outputs.each { output -> | |
// Stores the value of ext.abiCodes that is associated with the ABI for this variant. | |
def baseAbiVersionCode = | |
// Determines the ABI for this variant and returns the mapped value. | |
project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) | |
// Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes, | |
// the following code does not override the version code for universal APKs. | |
// However, because we want universal APKs to have the lowest version code, | |
// this outcome is desirable. | |
if (baseAbiVersionCode != null) { | |
// Assigns the new version code to versionCodeOverride, which changes the version code | |
// for only the output APK, not for the variant itself. Skipping this step simply | |
// causes Gradle to use the value of variant.versionCode for the APK. | |
output.versionCodeOverride = | |
baseAbiVersionCode * 1000 + variant.versionCode | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment