Skip to content

Instantly share code, notes, and snippets.

@marcohc
Last active April 13, 2021 04:23
Show Gist options
  • Save marcohc/22399bc35eb959f35989 to your computer and use it in GitHub Desktop.
Save marcohc/22399bc35eb959f35989 to your computer and use it in GitHub Desktop.
Generate multiple apks for different architectures using Gradle
apply plugin: 'com.android.application'
android {
// To create different apk per abi
splits {
abi {
enable true
reset()
include 'armeabi', 'armeabi-v7a', 'x86'
universalApk true
}
}
}
import com.android.build.OutputFile
// Map for the version code
ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'x86': 3]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
int abiVersionCode = project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) ?: 0
output.versionCodeOverride = (abiVersionCode * 1000) + android.defaultConfig.versionCode
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment