Android: signed, smaller release APKs

Release builds now come out one APK per ABI, signed from a gitignored
keystore.properties. Oboe is built from source with libopus and a static
libc++ into the one native library, which exports only its JNI entry
points; dex and native code are compressed in the APK and library
translations dropped. The arm64 APK went from 11.6 MB to 5.5 MB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 12:23:09 +00:00
co-authored by Claude Opus 5.5
parent 44ecc15bd8
commit 55e8b7bccb
5 changed files with 58 additions and 15 deletions
+39 -2
View File
@@ -1,3 +1,5 @@
import java.util.Properties
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.compose)
@@ -66,6 +68,14 @@ androidComponents {
}
}
/**
* Release signing from keystore.properties (storeFile, storePassword, keyAlias, keyPassword),
* kept out of the repository; without it the release APK is left unsigned.
*/
val releaseKeystore = rootDir.resolve("keystore.properties").takeIf { it.isFile }?.let { file ->
Properties().apply { file.inputStream().use(::load) }
}
android {
namespace = "com.ts3client.android"
compileSdk = 37
@@ -77,19 +87,43 @@ android {
targetSdk = 36
versionCode = 1
versionName = "0.1.0"
ndk {
abiFilters += listOf("arm64-v8a", "x86_64")
}
signingConfigs {
if (releaseKeystore != null) {
create("release") {
storeFile = file(releaseKeystore.getProperty("storeFile"))
storePassword = releaseKeystore.getProperty("storePassword")
keyAlias = releaseKeystore.getProperty("keyAlias")
keyPassword = releaseKeystore.getProperty("keyPassword")
}
}
}
// One APK per ABI for releases; debug builds stay a single APK for both.
splits {
abi {
isEnable = gradle.startParameter.taskNames.any { it.contains("Release") }
reset()
include("arm64-v8a", "x86_64")
isUniversalApk = false
}
}
buildTypes {
release {
signingConfig = signingConfigs.findByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
androidResources {
// The app is English only; drops the libraries' translations.
localeFilters += "en"
}
buildFeatures {
compose = true
}
@@ -100,6 +134,9 @@ android {
}
packaging {
// Compressed in the APK, which then is smaller to send; extracted on install.
dex.useLegacyPackaging = true
jniLibs.useLegacyPackaging = true
resources {
// BouncyCastle ships Java 9+ module metadata Android has no use for.
excludes += "META-INF/versions/9/OSGI-INF/MANIFEST.MF"