android:onClick not working with ProGuard

淺唱寂寞╮ 提交于 2019-11-30 15:19:39

You need to tell proguard not to mutate the method associated with your android:onClick tag.

Here is an example rule (taken from the proguard website):

-keep class mypackage.MyCallbackClass {
    void myCallbackMethod(java.lang.String);
}

in the example file in the android framework tools (YOUR_ANDROID_DIR/tools/proguard/proguard-android.txt), you can find the following rule:

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

With the comment it's quite explicit.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!