Skip to content

Commit

Permalink
TargetSdk back to 33. Added per ABI version codes
Browse files Browse the repository at this point in the history
  • Loading branch information
ElishaAz committed Oct 24, 2023
1 parent 614f0a3 commit 4c8bfe3
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ android {
defaultConfig {
applicationId "com.elishaazaria.sayboard"
minSdkVersion 23
targetSdkVersion 34
versionCode 4002
versionName "v4.0.2"
targetSdkVersion 33
versionCode 400030
versionName "v4.0.3"
}
buildTypes {
release {
Expand All @@ -30,7 +30,7 @@ android {
android.applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output ->
// output.outputFileName = "${variant.getFlavorName()}-${variant.buildType.name}-v${versionCode}_${versionName}-${new Date().format('ddMMMyyyy_HH-mm')}-${output.getFilter(com.android.build.OutputFile.ABI)}.apk"
var abi_name = output.getFilter(com.android.build.OutputFile.ABI) ? output.getFilter(com.android.build.OutputFile.ABI): "Universal"
var abi_name = output.getFilter(output.ABI) ? output.getFilter(output.ABI) : "Universal"
output.outputFileName = "Sayboard_${abi_name}.apk"
}
}
Expand Down Expand Up @@ -59,6 +59,39 @@ android {
}
}

//ext.abiCodes = ['armeabi-v7a':1, x86:2, x86_64:3]
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 * 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.configureEach { 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 variantVersionCode =
// Determines the ABI for this variant and returns the mapped value.
project.ext.abiCodes.get(output.getFilter(output.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 (variantVersionCode != 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 =
variant.versionCode + variantVersionCode
}
}
}

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.24.4"
Expand Down

0 comments on commit 4c8bfe3

Please sign in to comment.