perf: reduce APK size - switch to audio-only FFmpeg, enable ProGuard, split APK by ABI

This commit is contained in:
zarzet
2026-01-01 19:54:45 +07:00
parent d4d3a48167
commit c033c73a95
7 changed files with 77 additions and 16 deletions
+23 -2
View File
@@ -29,13 +29,34 @@ android {
versionCode = flutter.versionCode
versionName = flutter.versionName
multiDexEnabled = true
// Only include arm64-v8a for smaller APK (most modern devices)
// Remove this line if you need to support older 32-bit devices
ndk {
abiFilters += listOf("arm64-v8a", "armeabi-v7a")
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("debug")
isMinifyEnabled = false
isShrinkResources = false
// Enable code shrinking and resource shrinking
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
// Split APKs by ABI for smaller individual downloads
splits {
abi {
isEnable = true
reset()
include("arm64-v8a", "armeabi-v7a")
isUniversalApk = true // Also generate universal APK
}
}
}
+33
View File
@@ -0,0 +1,33 @@
# Flutter specific rules
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
# Go backend (gobackend.aar)
-keep class gobackend.** { *; }
-keep class go.** { *; }
# FFmpeg Kit
-keep class com.arthenica.ffmpegkit.** { *; }
-keep class com.arthenica.smartexception.** { *; }
# Keep native methods
-keepclasseswithmembernames class * {
native <methods>;
}
# Kotlin coroutines
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepclassmembers class kotlinx.coroutines.** {
volatile <fields>;
}
# Prevent R8 from removing metadata
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keepattributes Signature
-keepattributes Exceptions