I want to obfuscate only some packages:
com.foo.* com.bar.*
I have tried
-keepclasseswithmembers class **, !com.foo.**, !com.bar.** { *; }
and
-keepclasseswithmembers class !com.foo.** { *; } -keepclasseswithmembers class !com.bar.** { *; }
In both cases the classes from com.foo.* and com.bar.* was NOT obfuscated.
ProGuard is a command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods. It's an ideal fit for developers working with Java or Kotlin who are primarily interested in an Android optimizer.
You can obfuscate Android code to provide security against reverse engineering. You can use the Android ProGuard tool to obfuscate, shrink, and optimize your code.
Obfuscating package names myapplication. MyMain is the main application class that is kept by the configuration. All other class names can be obfuscated. Note that not all levels of obfuscation of package names may be acceptable for all code.
This should work
-keep class !com.foo.**,!com.bar.** { *; }
You can find a summary of the various -keep options at https://www.guardsquare.com/manual/configuration/usage#keepoptions
You can find the explanation of ProGuard's regular expressions at https://www.guardsquare.com/manual/configuration/usage#filters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With