The question is published on by Tutorial Guruji team.
I have an app published in the play store with proguard rules enable and I am receiving some error reports from Android versions 4.4 and 4.2 with this trace error
java.lang.IllegalStateException: at android.view.View$1.onClick (View.java:3949) at android.view.View.performClick (View.java:4633) at android.view.View$PerformClick.run (View.java:19270) at android.os.Handler.handleCallback (Handler.java:733) at android.os.Handler.dispatchMessage (Handler.java:95) at android.os.Looper.loop (Looper.java:146) at android.app.ActivityThread.main (ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative (Method.java) at java.lang.reflect.Method.invoke (Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1099) at dalvik.system.NativeStart.main (NativeStart.java) Caused by: java.lang.NoSuchMethodException: at java.lang.Class.getConstructorOrMethod (Class.java:472) at java.lang.Class.getMethod (Class.java:857) at android.view.View$1.onClick (View.java:3942) at android.view.View.performClick (View.java:4633) at android.view.View$PerformClick.run (View.java:19270) at android.os.Handler.handleCallback (Handler.java:733) at android.os.Handler.dispatchMessage (Handler.java:95) at android.os.Looper.loop (Looper.java:146) at android.app.ActivityThread.main (ActivityThread.java:5602) at java.lang.reflect.Method.invokeNative (Method.java) at java.lang.reflect.Method.invoke (Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1283) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1099) at dalvik.system.NativeStart.main (NativeStart.java)
As there is no reference to the method
that is been called or the Activity
and I am not able to reproduce it, I have no idea how could I fix it. (Most of the project is in java although some classes are in kotlin)
In the proguard file I have excluded domain models and some retrofit clasess, like:
# Application classes that will be serialized/deserialized over Gson -keep class com.example.mypackage.DataModel.** { *; } -keep class com.example.mypackage.WS.** { *; }
Thanks in advance!
Answer
While updating the project (gradle version, appCompat -> androidX …) I was forced to correct some lint uses, and one of them was to change a custom TextView that extended TextView to AppCompatTextView.
I had forgotten that in old Android versions when you extend a custom view from AppCompatView all your xml onClick properties no longer work, and NoSuchMethodException is thrown.
You can find some references here: