@supern Process: com.patchtest, PID: 2695 java.lang.IllegalArgumentException: Expected receiver of type com.patchtest.MainActivity_CF, but got com.patchtest.MainActivity at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284) at android.view.View.performClick(View.java:4909) at android.view.View$PerformClick.run(View.java:20390) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5826) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1009) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:804)
4条答案
按热度按时间0aydgbwb1#
@maxZhou7 有具体堆栈信息吗
ffscu2ro2#
@supern
Process: com.patchtest, PID: 2695
java.lang.IllegalArgumentException: Expected receiver of type com.patchtest.MainActivity_CF, but got com.patchtest.MainActivity
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:284)
at android.view.View.performClick(View.java:4909)
at android.view.View$PerformClick.run(View.java:20390)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5826)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1009)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:804)
bwleehnv3#
@supern
现已发现出现该问题是因为在xml中设置的点击android:onClick="btnClick"。我修改成代码中设置点击事件,然后修复点击执行的内容 就没有问题并成功修复了。btn_.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(View v) {
//todo
}
});
so,为什么不能在xml中直接设置android:onClick="btnClick"。
x7rlezfr4#
@maxZhou7 这是个已知问题,会后续修复的