Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-FileCopyrightText: 2017-2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import com.android.build.api.variant.FilterConfiguration
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
Expand Down Expand Up @@ -42,6 +43,15 @@ val media3Version = "1.11.1"
val coroutinesVersion = "1.11.0"
val mockitoKotlinVersion = "6.4.0"

val abiSplit = project.hasProperty("abiSplit")
val abiVersionCodes = mapOf("armeabi-v7a" to 1, "arm64-v8a" to 2, "x86" to 3, "x86_64" to 4)
val majorVersionCodeMultiplier = 10_000_000
val abiVersionCodeMultiplier = 10

fun abiVersionCode(versionCode: Int, abiCode: Int): Int =
versionCode / majorVersionCodeMultiplier * majorVersionCodeMultiplier +
versionCode % majorVersionCodeMultiplier * abiVersionCodeMultiplier + abiCode

android {
compileSdk = 37

Expand Down Expand Up @@ -133,6 +143,15 @@ android {
}
}

if (abiSplit) {
splits.abi {
isEnable = true
reset()
include(*abiVersionCodes.keys.toTypedArray())
isUniversalApk = false
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -163,6 +182,15 @@ android {
}
}

androidComponents.onVariants { variant ->
variant.outputs.forEach { output ->
val abi = output.filters.find { it.filterType == FilterConfiguration.FilterType.ABI }?.identifier
?: return@forEach
val abiCode = abiVersionCodes.getValue(abi)
output.versionCode.set(abiVersionCode(output.versionCode.get(), abiCode))
}
}

tasks.named("check") {
dependsOn("spotbugsGplayDebug", "lint", "ktlintCheck", "detekt")
}
Expand Down
Loading