Last active
July 19, 2020 15:17
-
-
Save BouweCeunen/8085544bfbc6f339a80ca4e69a35b8e8 to your computer and use it in GitHub Desktop.
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
import com.android.build.OutputFile | |
def keystoreProperties = new Properties() | |
def keystorePropertiesFile = rootProject.file('key.properties') | |
if (keystorePropertiesFile.exists()) { | |
keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) | |
} | |
/** | |
* Set this to true to create two separate APKs instead of one: | |
* - An APK that only works on ARM devices | |
* - An APK that only works on x86 devices | |
* The advantage is the size of the APK is reduced by about 4MB. | |
* Upload all the APKs to the Play LoginStore and people will download | |
* the correct one based on the CPU architecture of their device. | |
*/ | |
def enableSeparateBuildPerCPUArchitecture = false | |
android { | |
splits { | |
abi { | |
reset() | |
enable enableSeparateBuildPerCPUArchitecture | |
universalApk false // If true, also generate a universal APK | |
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" | |
} | |
} | |
applicationVariants.all { variant -> | |
variant.outputs.each { output -> | |
// For each separate APK per architecture, set a unique version code as described here: | |
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits | |
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] | |
def abi = output.getFilter(OutputFile.ABI) | |
if (abi != null) { // null for the universal-debug, universal-release variants | |
output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode | |
} | |
} | |
} | |
signingConfigs { | |
release { | |
keyAlias keystoreProperties['keyAlias'] | |
keyPassword keystoreProperties['keyPassword'] | |
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null | |
storePassword keystoreProperties['storePassword'] | |
} | |
} | |
buildTypes { | |
release { | |
signingConfig signingConfigs.release | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment