From e891bf83eb1631f07ea47c4c2e18dc88797bbba8 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Fri, 30 Oct 2026 06:57:11 +0300 Subject: [PATCH 1/2] split apk for only f-droid Signed-off-by: alperozturk96 --- app/build.gradle.kts | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c822052f1d13..f3e55dd8eea2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -7,6 +7,7 @@ */ @file:Suppress("UnstableApiUsage", "DEPRECATION") +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 @@ -17,6 +18,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget val shotTest = System.getenv("SHOT_TEST") == "true" val ciBuild = System.getenv("CI") == "true" val perfAnalysis = project.hasProperty("perfAnalysis") +val abiSplit = project.hasProperty("abiSplit") val allAbis = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") val localDebugAbis = when (System.getProperty("os.arch")) { @@ -24,6 +26,14 @@ val localDebugAbis = when (System.getProperty("os.arch")) { else -> listOf("arm64-v8a", "x86_64") } +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 + plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.compose) @@ -132,16 +142,20 @@ android { enable = true } buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"") - ndk { - abiFilters += allAbis + if (!abiSplit) { + ndk { + abiFilters += allAbis + } } } debug { enableUnitTestCoverage = project.hasProperty("coverage") enableAndroidTestCoverage = project.hasProperty("coverage") resConfigs("xxxhdpi") - ndk { - abiFilters += if (ciBuild) allAbis else localDebugAbis + if (!abiSplit) { + ndk { + abiFilters += if (ciBuild) allAbis else localDebugAbis + } } } } @@ -191,6 +205,15 @@ android { pickFirsts.add("MANIFEST.MF") // workaround for duplicated manifest on some dependencies } + if (abiSplit) { + splits.abi { + isEnable = true + reset() + include(*allAbis.toTypedArray()) + isUniversalApk = false + } + } + buildFeatures { buildConfig = true viewBinding = true @@ -240,6 +263,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)) + } +} + ksp.arg("room.schemaLocation", "$projectDir/schemas") // Configure KSP for test variants From f7657d00ff5794035c193f4f7fae1e8dc62da969 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Mon, 2 Nov 2026 17:45:32 +0300 Subject: [PATCH 2/2] use gradle script from config Signed-off-by: alperozturk96 --- app/build.gradle.kts | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f3e55dd8eea2..c822052f1d13 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -7,7 +7,6 @@ */ @file:Suppress("UnstableApiUsage", "DEPRECATION") -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 @@ -18,7 +17,6 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget val shotTest = System.getenv("SHOT_TEST") == "true" val ciBuild = System.getenv("CI") == "true" val perfAnalysis = project.hasProperty("perfAnalysis") -val abiSplit = project.hasProperty("abiSplit") val allAbis = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") val localDebugAbis = when (System.getProperty("os.arch")) { @@ -26,14 +24,6 @@ val localDebugAbis = when (System.getProperty("os.arch")) { else -> listOf("arm64-v8a", "x86_64") } -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 - plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.compose) @@ -142,20 +132,16 @@ android { enable = true } buildConfigField("String", "NC_TEST_SERVER_DATA_STRING", "\"\"") - if (!abiSplit) { - ndk { - abiFilters += allAbis - } + ndk { + abiFilters += allAbis } } debug { enableUnitTestCoverage = project.hasProperty("coverage") enableAndroidTestCoverage = project.hasProperty("coverage") resConfigs("xxxhdpi") - if (!abiSplit) { - ndk { - abiFilters += if (ciBuild) allAbis else localDebugAbis - } + ndk { + abiFilters += if (ciBuild) allAbis else localDebugAbis } } } @@ -205,15 +191,6 @@ android { pickFirsts.add("MANIFEST.MF") // workaround for duplicated manifest on some dependencies } - if (abiSplit) { - splits.abi { - isEnable = true - reset() - include(*allAbis.toTypedArray()) - isUniversalApk = false - } - } - buildFeatures { buildConfig = true viewBinding = true @@ -263,15 +240,6 @@ 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)) - } -} - ksp.arg("room.schemaLocation", "$projectDir/schemas") // Configure KSP for test variants