diff --git a/.changeset/shrink-foss-android-apk.md b/.changeset/shrink-foss-android-apk.md new file mode 100644 index 000000000..f8d8a5b24 --- /dev/null +++ b/.changeset/shrink-foss-android-apk.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Shrink the Android APK: strip the native library, drop bundled source maps, and split the F-Droid build per ABI. diff --git a/.github/workflows/tauri-build.yml b/.github/workflows/tauri-build.yml index adf3a41b7..1223c2240 100644 --- a/.github/workflows/tauri-build.yml +++ b/.github/workflows/tauri-build.yml @@ -326,7 +326,7 @@ jobs: echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties # Must run before the Google build: they share one Gradle output directory. - - name: Build FOSS Android APK + - name: Build FOSS Android APKs if: ${{ env.IS_RELEASE == 'true' }} shell: bash env: @@ -335,13 +335,16 @@ jobs: # tauri-build validates every file in capabilities/, so the geolocation # permissions must be absent, not just unreferenced. rm src-tauri/capabilities/geolocation.json - pnpm tauri android build --apk --target aarch64 armv7 -- --no-default-features --features wry,matrix-crypto + pnpm tauri android build --apk --split-per-abi --target aarch64 armv7 -- --no-default-features --features wry,matrix-crypto git checkout -- src-tauri/capabilities/geolocation.json - OUT='src-tauri/gen/android/app/build/outputs/apk/universal/release' - APK=$(find "$OUT" -name '*.apk' -type f | head -1) - [ -n "$APK" ] || { echo 'FOSS APK not found' >&2; exit 1; } mkdir -p android-artifacts - mv "$APK" "android-artifacts/Sable-${VERSION}-android-universal-foss.apk" + for pair in 'arm64:arm64' 'arm:armv7'; do + FLAVOR=${pair%%:*} + ABI=${pair##*:} + APK=$(find "src-tauri/gen/android/app/build/outputs/apk/$FLAVOR/release" -name '*.apk' -type f | head -1) + [ -n "$APK" ] || { echo "FOSS $ABI APK not found" >&2; exit 1; } + mv "$APK" "android-artifacts/Sable-${VERSION}-android-${ABI}-foss.apk" + done - name: Build Android bundles shell: bash diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 71ad20ad3..48dbff9b4 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -243,3 +243,8 @@ tauri-typegen = { git = "https://github.com/SableClient/tauri-typegen", branch = # tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" } # tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" } # tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" } + +[profile.release] +strip = "symbols" +lto = "thin" +codegen-units = 1 diff --git a/src-tauri/gen/android/app/build.gradle.kts b/src-tauri/gen/android/app/build.gradle.kts index c65309122..d40f98bae 100644 --- a/src-tauri/gen/android/app/build.gradle.kts +++ b/src-tauri/gen/android/app/build.gradle.kts @@ -58,6 +58,9 @@ android { getByName("release") { signingConfig = signingConfigs.getByName("release") isMinifyEnabled = true + packaging { + jniLibs.useLegacyPackaging = true + } proguardFiles( *fileTree(".") { include("**/*.pro") } .plus(getDefaultProguardFile("proguard-android-optimize.txt")) diff --git a/vite.config.ts b/vite.config.ts index aa91ce9aa..6dfb3fb83 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -80,7 +80,7 @@ const callEmbeddedDir = 'node_modules/@sableclient/sable-call-embedded/dist'; const copyFiles = { targets: [ { - src: callEmbeddedDir, + src: [callEmbeddedDir, `!${callEmbeddedDir}/**/*.map`], dest: 'public/element-call', rename: { stripBase: callEmbeddedDir.split('/').length }, },