Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a classes from being kept by proguard

I added the following line in my proguard config:

 -keep class com.mypackage.** {*;}

But now proguard doesn't remove my class com.mypackage.BuildConfig.class from the result. And I want it to be removed.

How can I exclude a given class from being kept?

Thanks

like image 262
Addev Avatar asked Dec 09 '16 12:12

Addev


People also ask

Does ProGuard remove unused classes?

ProGuard Facts:Helps to remove unused classes, members & fields. It removes unused codes from your libraries as well. (Which means, any method or field that is not referenced anywhere will be removed by ProGuard Shrinker). Helps to reduce the build size by obfuscating the classes, methods, & fields with short names.

What is keep class in ProGuard?

Specifies classes and class members whose names are to be preserved, if they aren't removed in the shrinking phase. For example, you may want to keep all class names of classes that implement the Serializable interface, so that the processed code remains compatible with any originally serialized classes.

How do you keep all classes in ProGuard?

-keepclassmembernames. This is the most permissive keep directive; it lets ProGuard do almost all of its work. Unused classes are removed, the remaining classes are renamed, unused members of those classes are removed, but then the remaining members keep their original names.


1 Answers

You can use the following rule:

-keep class !com.mypackage.BuildConfig, com.mypackage.** { *; }
like image 50
T. Neidhart Avatar answered Sep 28 '22 05:09

T. Neidhart