question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is the correct proguard?

See original GitHub issue

Hi, team, when my project is using StateSaver in Activity/Fragment, it’s fine, because default proguard will keep the name for system views. but when I use for custom file, it can not find injector because of obfuscate.

I check the README, it shows This library comes with a ProGuard config. No further steps are required, but all necessary rules can be found here.

I checked the sample, it’s

-dontwarn com.evernote.android.state.**
-keep class com.evernote.android.state.** { *; }
-keep class **$$StateSaver { *; }
-keepclassmembers class * {
    @com.evernote.android.state.StateReflection <fields>;
}

it will keep the generate class, but it won’t keep the class with @State annotation, I don’t know what is StateReflection.

then I change it to

-dontwarn com.evernote.android.state.**
-keep class com.evernote.android.state.** { *; }
-keep class **$$StateSaver { *; }
-keepclasseswithmembernames class * {
    @com.evernote.android.state.* <fields>;
 }
-keepnames class * { @com.evernote.android.state.State *;}

it works.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
vRallevcommented, Jun 21, 2017

Yes, the rule -keepnames class * { @com.evernote.android.state.State *;} seems to be necessary. Good catch!

The downside is that this rule also preserves the variable names, although they could be obfuscated. But I didn’t find a proguard rule that only keeps the class name and not variable names although they’re matching.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring ProGuard | CodePath Android Cliffnotes
ProGuard is a tool to help minify, obfuscate, and optimize your code. It is not only especially useful for reducing the overall size...
Read more >
Java Obfuscator and Android App Optimizer | ProGuard
ProGuard is a command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods. It's an...
Read more >
Android Proguard, obfuscation, reduce app size - Medium
What is Proguard? ProGuard is a free Java tool in Android that performs three major roles: 1. Shrink/minify the code (remove unused code...
Read more >
ProGuard in Android - GeeksforGeeks
Proguard is a great tool for creating a production-ready application in Android. It assists us in reducing code and making apps faster. Proguard ......
Read more >
What is the correct ProGuard definition for latest mp4parser ...
Tested with mp4parser version 1.1.7: -keep class * implements com.coremedia.iso.boxes.Box { *; } -dontwarn com.coremedia.iso.boxes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found