From e267e15e9fd0dbcff55e548aa92932034157aa21 Mon Sep 17 00:00:00 2001 From: AnatolyJacobs Date: Wed, 8 Apr 2026 12:56:10 +0300 Subject: [PATCH 1/2] Fix Picocli ProGuard rules to prevent runtime crashes Updates the ProGuard configuration to explicitly keep reflection annotations, Kotlin companion objects, Picocli subcommands/help mixins, and IPC data classes that were being aggressively stripped by R8. --- daemon/proguard-rules.pro | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daemon/proguard-rules.pro b/daemon/proguard-rules.pro index 4f1bd0b1a..b317d3050 100644 --- a/daemon/proguard-rules.pro +++ b/daemon/proguard-rules.pro @@ -7,6 +7,19 @@ -keepclasseswithmembers class org.matrix.vector.daemon.Cli { public static void main(java.lang.String[]); } +-keep class org.matrix.vector.daemon.Cli { *; } +-keep class org.matrix.vector.daemon.Cli$Companion { *; } +-keep class org.matrix.vector.daemon.*Command { *; } +-keep class org.matrix.vector.daemon.CliRequest { *; } +-keep class org.matrix.vector.daemon.CliResponse { *; } + +-keep class picocli.CommandLine$AutoHelpMixin { *; } +-keep class picocli.CommandLine$HelpCommand { *; } +-keep @picocli.CommandLine$Command class picocli.** { *; } + +# MUST keep annotations for Picocli to function via reflection +-keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod + -keepclasseswithmembers class org.matrix.vector.daemon.env.LogcatMonitor { private int refreshFd(boolean); } From ef4e29aa83415a231197dafcb0b9f32cc07d9423 Mon Sep 17 00:00:00 2001 From: JingMatrix Date: Wed, 8 Apr 2026 13:24:57 +0200 Subject: [PATCH 2/2] Resolve Picocli InitializationException in release builds R8 minification was aggressively stripping Picocli annotations (@Command, @Option) and renaming command classes, causing reflection to fail at runtime. We add targeted ProGuard rules to ensure CLI stability: - Preserved attributes required for reflection and annotations. - Protected any class or member annotated with Picocli markers. - Kept internal Picocli classes required for standard help mixins. - Retained Gson IPC data models (CliRequest/Response) to prevent socket serialization failures in release builds. --- daemon/proguard-rules.pro | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/daemon/proguard-rules.pro b/daemon/proguard-rules.pro index b317d3050..ab73abb05 100644 --- a/daemon/proguard-rules.pro +++ b/daemon/proguard-rules.pro @@ -7,18 +7,29 @@ -keepclasseswithmembers class org.matrix.vector.daemon.Cli { public static void main(java.lang.String[]); } --keep class org.matrix.vector.daemon.Cli { *; } --keep class org.matrix.vector.daemon.Cli$Companion { *; } --keep class org.matrix.vector.daemon.*Command { *; } + + +# Keep IPC data models intact so Gson serializes the correct JSON keys -keep class org.matrix.vector.daemon.CliRequest { *; } -keep class org.matrix.vector.daemon.CliResponse { *; } +# Preserve annotations, generic signatures, and inner classes (critical for picocli reflection) +-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod + +# Keep internal Picocli classes required for `mixinStandardHelpOptions = true` -keep class picocli.CommandLine$AutoHelpMixin { *; } -keep class picocli.CommandLine$HelpCommand { *; } --keep @picocli.CommandLine$Command class picocli.** { *; } -# MUST keep annotations for Picocli to function via reflection --keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod +# Keep ANY class (and its constructor) annotated with @Command +-keep @picocli.CommandLine$Command class * { + (...); +} + +# Keep ANY field/method using a Picocli annotation (@Option, @Parameters, etc.) +-keepclassmembers class * { + @picocli.CommandLine$* *; +} + -keepclasseswithmembers class org.matrix.vector.daemon.env.LogcatMonitor { private int refreshFd(boolean);