Android, ProGuard, and keepclasseswithmembernames

前端 未结 2 1950
一整个雨季
一整个雨季 2020-12-31 19:15

A common pattern in ProGuard configs for Android applications is to preserve custom View classes, since they are probably referenced only from layout XML instea

相关标签:
2条回答
  • 2020-12-31 19:49

    The configuration in the Android SDK (at least up to version 11) is not entirely correct, indeed.

    The configuration for Android in the ProGuard documentation correctly specifies "-keepclasseswithmembers", not "-keepclasseswithmembernames".

    0 讨论(0)
  • 2020-12-31 19:51

    When I first tried the integrated proguard with Ant, my app kept crashing with runtime errors on the clickhandlers. (I always set these in XML). I assumed I must be doing something wrong, couldn't work out what, so added the line

    -dontshrink
    

    at the top of the proguard.cfg.

    Maybe this isn't optimal but it stopped the run time errors!

    Addendum

    In fact I checked this by looking at usage.txt. The clickhandlers were listed in there before I added the dontshrink option, after I added it, usage.txt was empty as would be expected.

    0 讨论(0)
提交回复
热议问题