Proguard (R8) negate operator not working to keep anything except certain packages

I had to add ,** to get it working. Thanks T. Neidhart!

-keep class !org.apache.**,**

The previous example preserved class names but still obfuscated members. So I had to add { *; }:

-keep class !org.apache.**,** { *; }

That’s how I obfuscate multiple packages (I have to use them all in one keep rule!)

-keep class !org.apache.**, !org.zeroturnaround.**, !com.drew.**, ** { *; }

To find out what my problem is with -dontshrink -dontoptimize -dontobfuscate -keep,allowshrinking,allowoptimization,allowobfuscation class org.apache.** I could add -whyareyoukeeping according to https://www.guardsquare.com/en/products/proguard/manual/usage

Leave a Comment