From 6eaa1b8f75cb0cb2c7813fd3786f042f0823d56f Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 15 Jan 2024 09:41:01 -0300 Subject: [wallet] add option to create ABI split APKs --- wallet/build.gradle | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'wallet') diff --git a/wallet/build.gradle b/wallet/build.gradle index 23c8a0b..cde5efd 100644 --- a/wallet/build.gradle +++ b/wallet/build.gradle @@ -60,6 +60,8 @@ android { fdroid { dimension "distributionChannel" applicationIdSuffix ".fdroid" + // version codes get multiplied by 10 and an ABI suffix gets added to the code + // if 'splitApk' property is set } google { dimension "distributionChannel" @@ -101,6 +103,15 @@ android { excludes += ['META-INF/*.kotlin_module'] } } + splits { + abi { + // can not be defined per flavor, so we use a property to turn this on for F-Droid + enable project.hasProperty('splitApk') + reset() // Resets the list of ABIs to remove all included by default + include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" + universalApk false + } + } lint { abortOnError true @@ -167,3 +178,20 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" } } + +// Map for the version code that gives each ABI a value. +ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4] +// For each APK output variant, override versionCode with a combination of ext.abiCodes + variant.versionCode. +android.applicationVariants.configureEach { variant -> + // Assigns a different version code for each output 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(com.android.build.OutputFile.ABI)) + if (baseAbiVersionCode != null) { + output.versionCodeOverride = 10 * variant.versionCode + baseAbiVersionCode + } + // leaves version code alone of there's no baseAbiVersionCode + } +} -- cgit v1.2.3