Skip to content

Commit 5013b32

Browse files
authored
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.
1 parent e07bee5 commit 5013b32

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/build.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,16 @@ android {
4848

4949
// APK splits for GitHub releases - creates arm64, x86_64, and universal APKs
5050
// AAB for Play Store handles architecture distribution automatically
51+
// Auto-detects: splits enabled for assemble tasks, disabled for bundle tasks
52+
// Works in Android Studio GUI and CLI without needing extra properties
53+
val enableSplits = gradle.startParameter.taskNames.any { taskName ->
54+
taskName.contains("assemble", ignoreCase = true) &&
55+
!taskName.contains("bundle", ignoreCase = true)
56+
}
57+
5158
splits {
5259
abi {
53-
isEnable = true
60+
isEnable = enableSplits
5461
reset()
5562
include("arm64-v8a", "x86_64", "armeabi-v7a", "x86")
5663
isUniversalApk = true // For F-Droid and fallback

0 commit comments

Comments
 (0)