Last active
April 13, 2021 04:23
-
-
Save marcohc/22399bc35eb959f35989 to your computer and use it in GitHub Desktop.
Generate multiple apks for different architectures using Gradle
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
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