what is the difference between -keep class and -do

2020-07-05 09:52发布

问题:

Hey I'm new with proGuard , I use it to protect my code from reverse engineering , but when I built my signed apk I got a lot of errors when I enabled proGuard ,I have googled my problem I've found answers that says use -dontwarn for the classes that showing in the error message but after seeing the documentation from proGuard it says

If you don't feel like filtering out the problematic classes, you can try your luck with the -ignorewarnings option, or even the -dontwarn option. Only use these options if you really know what you're doing though.

and I don't know what I'm doing and here is my proguard-rules.pro file

-dontwarn okio.**
-dontwarn org.apache.**
-dontwarn com.appodeal.**
-dontwarn com.parse.**
-dontwarn com.squareup.**

and I've seen some answers says use -keep class

so can someone explain it

回答1:

-keep class Preserve the specified classes and class members.

-dontwarn Don't warn about unresolved references at all.

More info here http://proguard.sourceforge.net/manual/refcard.html



回答2:

-dontwarn

Specifies not to warn about unresolved references and other important problems at all. The optional filter is a regular expression; ProGuard doesn't print warnings about classes with matching names. Ignoring warnings can be dangerous. For instance, if the unresolved classes or class members are indeed required for processing, the processed code will not function properly. Only use this option if you know what you're doing!

-keep class

Specifies classes and class members (fields and methods) to be preserved as entry points to your code. For example, in order to keep an application, you can specify the main class along with its main method. In order to process a library, you should specify all publicly accessible elements.

Hope this Helps!!