android:onClick not working with ProGuard

前端 未结 2 1768
独厮守ぢ
独厮守ぢ 2021-01-03 03:08

Since today, something weird is happening with my application. Every time I click a button that has set the android:onClick attribute, I get an IllegalStateException: Co

2条回答
  •  半阙折子戏
    2021-01-03 04:01

    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.

提交回复
热议问题