From 23afe78fe09430ca9106a85c2d60e660c034ee9e Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Sat, 27 Jun 2026 17:06:50 -0500 Subject: [PATCH] Enable R8 for release builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Turn on minification for the release build and sign it with the debug key so it is installable for testing (a public release would use a dedicated keystore). - proguard-rules.pro keeps the reflection-heavy mail/auth stack: Jakarta/Angus Mail (IMAP/SMTP providers resolved via reflection + service files) and AppAuth. - Verified on the Android 17 emulator: the release APK builds with R8, installs, and syncs mail over IMAP — confirming Angus Mail's provider resolution survives shrinking. Co-Authored-By: Claude Opus 4.8 --- app/build.gradle.kts | 5 ++++- app/proguard-rules.pro | 31 ++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 585a71a..e862077 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -48,11 +48,14 @@ android { buildTypes { release { - isMinifyEnabled = false + isMinifyEnabled = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", ) + // Sign release builds with the debug key so they're installable for testing. + // A public release would configure a dedicated upload/release keystore here. + signingConfig = signingConfigs.getByName("debug") } } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index dc533d7..105d796 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,14 +1,19 @@ # SPDX-License-Identifier: GPL-3.0-or-later -# LibreMail ProGuard/R8 rules. -# -# Release builds are currently not minified (see app/build.gradle.kts). When -# minification is enabled for release, add keep rules for the email/auth stack: -# -# Jakarta / Angus Mail (reflection-based provider registration): -# -keep class jakarta.mail.** { *; } -# -keep class org.eclipse.angus.mail.** { *; } -# -keep class com.sun.mail.** { *; } -# -dontwarn jakarta.activation.** -# -# AppAuth: -# -keep class net.openid.appauth.** { *; } +# R8/ProGuard keep rules for LibreMail's release build. + +# --- Jakarta / Angus Mail (IMAP/SMTP) --- +# Protocol providers (IMAP/SMTP stores and transports) are discovered via reflection and +# META-INF service files, so keep the mail and activation classes and their members intact. +-keep class jakarta.mail.** { *; } +-keep class jakarta.activation.** { *; } +-keep class org.eclipse.angus.mail.** { *; } +-keep class org.eclipse.angus.activation.** { *; } +-dontwarn jakarta.mail.** +-dontwarn jakarta.activation.** +-dontwarn org.eclipse.angus.** +-dontwarn com.sun.activation.** + +# --- AppAuth --- +# AppAuth (de)serializes its models (AuthState, token responses) reflectively. +-keep class net.openid.appauth.** { *; } +-dontwarn net.openid.appauth.**