I am using proguard to obfuscate my android application. The android application contains some native code, which makes callbacks to fully qualified java methods. I need to not obfuscate these classes and the names of their methods. The below properly keeps the class names, but not the method names.
-keep public class com.me.dontobf.* -keepnames public class com.me.dontobf.*
-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.
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.
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.
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.
For native methods: ProGuard manual > Examples > Processing native methods
# note that <methods> means any method -keepclasseswithmembernames,includedescriptorclasses class * { native <methods>; }
In this case, for callback methods: ProGuard manual > Examples > Processing callback methods
-keep class mypackage.MyCallbackClass { void myCallbackMethod(java.lang.String); }
Or e.g., if all public methods may be callback methods:
-keep class mypackage.MyCallbackClass { public <methods>; }
You probably also need to keep any program classes that occur in the method descriptors.
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