Skip to content

Commit

Permalink
Merge pull request #116 from grote/fdroid-splits
Browse files Browse the repository at this point in the history
Add F-Droid flavor with optional ABI splits
  • Loading branch information
akwizgran committed Jan 12, 2024
2 parents 151514f + a4c97b9 commit 98db703
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,28 @@ android {
stable {
dimension "releaseType"
}
fdroid {
dimension "releaseType"
applicationIdSuffix ".fdroid"
// version codes get multiplied by 10 and an ABI suffix gets added to the code
// if 'splitApk' property is set
}
nightly {
dimension "releaseType"
applicationIdSuffix ".nightly"
versionCode versionCodeEpoch()
versionNameSuffix " ($gitCommit)"
}
}
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
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -151,6 +166,23 @@ dependencies {
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
}

// 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
}
}

def torLibsDir = 'src/main/jniLibs'

task cleanTorBinaries {
Expand Down

0 comments on commit 98db703

Please sign in to comment.