Skip to content

Commit

Permalink
Don't add 2000 to arm64-v8a versionCode arch on build
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Oct 9, 2023
1 parent e6ddd44 commit bc7fcbd
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,40 @@ dependencies {
//implementation "moe.shizuku:manager:$shizuku_version"
}



// Map for the version code that gives each ABI a value.
ext.abiCodes = ['arm64-v8a': 0, 'armeabi-v7a': 1, x86_64: 2]

// For per-density APKs, create a similar map:
// ext.densityCodes = ['mdpi': 1, 'hdpi': 2, 'xhdpi': 3]

import com.android.build.OutputFile

// For each APK output variant, override versionCode with a combination of
// ext.abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode
// is equal to defaultConfig.versionCode. If you configure product flavors that
// define their own versionCode, variant.versionCode uses that value instead.
android.applicationVariants.all { variant ->

// Assigns a different version code for each output APK
// other than the universal 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(OutputFile.ABI))

// Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
// the following code doesn't override the version code for universal APKs.
// However, because you want universal APKs to have the lowest version code,
// this outcome is desirable.
if (baseAbiVersionCode != null) {

// Assigns the new version code to versionCodeOverride, which changes the
// version code for only the output APK, not for the variant itself. Skipping
// this step causes Gradle to use the value of variant.versionCode for the APK.
output.versionCodeOverride =
baseAbiVersionCode * 1000 + variant.versionCode
}
}
}

0 comments on commit bc7fcbd

Please sign in to comment.