frankiesardo / icepick

Android Instance State made easy
Eclipse Public License 1.0
3.75k stars 208 forks source link

Proguard issues with code obfuscation #97

Open ouyangzn opened 7 years ago

ouyangzn commented 7 years ago

Hi guys, there is a problem, if i add this line, all class name will not be obfuscated, it seems not so well. How can i resolve it?

-keepnames class * { @icepick.State *;}
pamalyshev commented 7 years ago

This rule seems to be unnecessary and wrong. If I understand ProGuard docs correctly this rule means "Keep names of all classes that were not removed AND ALSO keep names of members that are annotated with @State.

I removed this rule, so now I have:

-dontwarn icepick.**
-keep class icepick.** { *; }
-keep class **$$Icepick { *; }

-keepclasseswithmembernames class * {
    @icepick.* <fields>;
}

State restoration works, this seems to be the right set of rules. Unobvious thing here is that rule

-keepclasseswithmembernames class * {
    @icepick.* <fields>;
}

Won't work without -keep class icepick.** { *; } because @icepick.* annotations are removed.

phcannesson commented 6 years ago

I spent a few hours today investigating this issue before I found this topic. So I created a pull request to remove the line from README and avoid the pain to others.