Skip to content

Fix Picocli ProGuard rules to prevent runtime crashes#645

Merged
JingMatrix merged 2 commits intoJingMatrix:masterfrom
AnatolyJacobs:cli_fix
Apr 8, 2026
Merged

Fix Picocli ProGuard rules to prevent runtime crashes#645
JingMatrix merged 2 commits intoJingMatrix:masterfrom
AnatolyJacobs:cli_fix

Conversation

@AnatolyJacobs
Copy link
Copy Markdown
Contributor

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.

@JingMatrix When trying to use the command line interface in the release version, I get the following message.

FATAL EXCEPTION: main (Show original)
PID: 15311
picocli.CommandLine$InitializationException: class xh is not a command: it has no @command, @option, @parameters or @unmatched annotations
at picocli.CommandLine$PicocliException.(CommandLine.java:18581)
at picocli.CommandLine$InitializationException.(CommandLine.java:18588)
at picocli.CommandLine$Model$CommandReflection.validateCommandSpec(CommandLine.java:12052)
at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:11882)
at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:6396)
at picocli.CommandLine.(CommandLine.java:230)
at picocli.CommandLine.toCommandLine(CommandLine.java:3639)
at picocli.CommandLine.access$16800(CommandLine.java:148)
at picocli.CommandLine$Model$CommandReflection.initSubcommands(CommandLine.java:11907)
at picocli.CommandLine$Model$CommandReflection.extractCommandSpec(CommandLine.java:11873)
at picocli.CommandLine$Model$CommandSpec.forAnnotatedObject(CommandLine.java:6396)
at picocli.CommandLine.(CommandLine.java:230)
at picocli.CommandLine.(CommandLine.java:224)
at picocli.CommandLine.(CommandLine.java:199)
at org.matrix.vector.daemon.Cli$Companion.main(Cli.kt:230)
at org.matrix.vector.daemon.Cli.main(Cli.kt)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:470)

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.
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.
@JingMatrix JingMatrix merged commit e811522 into JingMatrix:master Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants