java.lang.IllegalStateException

Could not execute method for android:onClick


Samebug tips3

You have an empty cursor. Check your query if it is not expected, or handle empty cursor with if(cursor.getCount() > 0) ...

You need to make sure that there is a data in the cursor. Check that moveToFirst() return true.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.


Solutions on the web19941

Solution icon of github
via GitHub by svalo
, 1 year ago
Could not execute method for android:onClick

Solution icon of github
via GitHub by btusca
, 1 year ago
Could not execute method for android:onClick

Solution icon of github
via GitHub by ascoril
, 9 months ago
Could not execute method for android:onClick

Solution icon of github
Could not execute method for android:onClick

Solution icon of github
via GitHub by jkwok678
, 1 year ago
Could not execute method for android:onClick

Solution icon of github
Could not execute method for android:onClick

Solution icon of github
Could not execute method for android:onClick

Solution icon of github
Could not execute method for android:onClick

Solution icon of stackoverflow
Could not execute method for android:onClick

Solution icon of stackoverflow
Could not execute method for android:onClick

Stack trace

  • java.lang.IllegalStateException: Could not execute method for android:onClick at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293) at android.view.View.performClick(View.java:5226) at android.view.View$PerformClick.run(View.java:21266) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:168) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) ... 9 more Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 at android.database.AbstractCursor.checkPosition(AbstractCursor.java:460) at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136) at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50) at com.pos.example.LoginActivity.checkLogin(LoginActivity.java:69) at com.pos.example.LoginActivity.onClick(LoginActivity.java:40) at java.lang.reflect.Method.invoke(Native Method) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) at android.view.View.performClick(View.java:5226) at android.view.View$PerformClick.run(View.java:21266) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:168) at android.app.ActivityThread.main(ActivityThread.java:5845) at java.lang.reflect.Method.invoke(Native Method)

Write tip

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

Users with the same issue

Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
2 times, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
Samebug visitor profile picture
Unknown user
Once, 1 year ago
51 more bugmates