In proguard, how to preserve a set of classes’ method 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.

Try:

-keepclasseswithmembernames class * {
    native <methods>;
}

From the ProGuard manual: http://proguard.sourceforge.net/manual/examples.html#native

Leave a Comment