From 5013b32ca9cecbbfc4e7c97362b00e9a47a50721 Mon Sep 17 00:00:00 2001 From: Moe Hamade <69801237+moehamade@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:06:15 +0200 Subject: [PATCH] feat: Introduce Gradle property to control APK splits (#560) * feat: Introduce Gradle property to control APK splits This commit introduces a new Gradle project property, `buildSplitApks`, to conditionally enable or disable the generation of ABI-specific (arm64, x86_64) and universal APKs. Key changes: - In `app/build.gradle.kts`, the `splits.abi.isEnable` flag is now dynamically set based on the `buildSplitApks` property. - APK splitting is disabled by default to support standard Android App Bundle (`bundleRelease`) builds. - The release workflow (`release.yml`) is updated to pass `-PbuildSplitApks=true` when building release APKs for GitHub. - The general Android build workflow (`android-build.yml`) is also modified to enable splits only for the `Release` variant, ensuring debug builds are not affected. * chore: Simplify and automate APK split builds This commit simplifies the build process by automatically enabling ABI splits for APKs (`assemble`) and disabling them for AABs (`bundle`). This removes the need to manually pass the `-PbuildSplitApks=true` property. The build script now intelligently determines whether to create architecture-specific APKs based on the task being executed (e.g., `assembleRelease` vs. `bundleRelease`). The GitHub Actions workflows (`release.yml`, `android-build.yml`) have been updated to remove this now-redundant property, streamlining the CI configuration. --- app/build.gradle.kts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bb5852b7..cc0f4457 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -48,9 +48,16 @@ android { // APK splits for GitHub releases - creates arm64, x86_64, and universal APKs // AAB for Play Store handles architecture distribution automatically + // Auto-detects: splits enabled for assemble tasks, disabled for bundle tasks + // Works in Android Studio GUI and CLI without needing extra properties + val enableSplits = gradle.startParameter.taskNames.any { taskName -> + taskName.contains("assemble", ignoreCase = true) && + !taskName.contains("bundle", ignoreCase = true) + } + splits { abi { - isEnable = true + isEnable = enableSplits reset() include("arm64-v8a", "x86_64", "armeabi-v7a", "x86") isUniversalApk = true // For F-Droid and fallback