Android: What are the recommended configurations for Proguard?

前端 未结 3 2112
礼貌的吻别
礼貌的吻别 2020-11-27 09:45

I\'m developing apps for Android and using Proguard to obfuscate the code.

Currently i\'m using ProGuard configurations:

-optimizationpasses 5
-dontu         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 10:09

    For standard builds with Ant or Eclipse, the Android SDK (r20 or higher) already provides a suitable configuration, referenced by the property proguard.config in the file project.properties (as Michal points out in his answer). In older releases, you always had to specify your own complete configuration, so older advice (like the first answer) can lead to some confusion.

    For custom builds, you can find the latest recommended configuration in the ProGuard manual > Examples > A complete Android application. The Proguard distribution also contains a sample file examples/android.pro

    Notably, you may want to preserve annotations, and setters in View extensions.

    You can add comments after a hash character '#', as extensively done in the sample files.

提交回复
热议问题