java.lang.IllegalStateException:Could not execute method for android:onClick












-1















I receive this error in crash report of just some users, but I don't understand it! The app works perfectly on almost all user devices!
This is not a duplicate question, because app works always, but crashes some times!



part of my code, shows the click is not something tricky:



fun grid_btn_clicked(v: View) {
showData(findJson(K1)!!)
}


and this is exception:




Fatal Exception: java.lang.IllegalStateException: Could not execute
method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:5716)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22596)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)











share|improve this question




















  • 1





    can you add some piece of code where its crashing ?

    – Faiz Mir
    Nov 13 '18 at 5:16











  • Please put showData function body. Most probably there is a null in some cases as u use !!, maybe try wrapping it with let to get secured from crashes

    – P.Juni
    Nov 13 '18 at 5:31













  • If there was problem in showData why exception raised here?!

    – AVEbrahimi
    Nov 13 '18 at 5:31











  • Dont really know because there is No code for other functions but if findJson can return null then u can get null in showData and in onClick

    – P.Juni
    Nov 13 '18 at 5:35






  • 1





    how have you set the click listener? If in the xml, then show the xml

    – Vladyslav Matviienko
    Nov 13 '18 at 5:39
















-1















I receive this error in crash report of just some users, but I don't understand it! The app works perfectly on almost all user devices!
This is not a duplicate question, because app works always, but crashes some times!



part of my code, shows the click is not something tricky:



fun grid_btn_clicked(v: View) {
showData(findJson(K1)!!)
}


and this is exception:




Fatal Exception: java.lang.IllegalStateException: Could not execute
method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:5716)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22596)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)











share|improve this question




















  • 1





    can you add some piece of code where its crashing ?

    – Faiz Mir
    Nov 13 '18 at 5:16











  • Please put showData function body. Most probably there is a null in some cases as u use !!, maybe try wrapping it with let to get secured from crashes

    – P.Juni
    Nov 13 '18 at 5:31













  • If there was problem in showData why exception raised here?!

    – AVEbrahimi
    Nov 13 '18 at 5:31











  • Dont really know because there is No code for other functions but if findJson can return null then u can get null in showData and in onClick

    – P.Juni
    Nov 13 '18 at 5:35






  • 1





    how have you set the click listener? If in the xml, then show the xml

    – Vladyslav Matviienko
    Nov 13 '18 at 5:39














-1












-1








-1








I receive this error in crash report of just some users, but I don't understand it! The app works perfectly on almost all user devices!
This is not a duplicate question, because app works always, but crashes some times!



part of my code, shows the click is not something tricky:



fun grid_btn_clicked(v: View) {
showData(findJson(K1)!!)
}


and this is exception:




Fatal Exception: java.lang.IllegalStateException: Could not execute
method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:5716)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22596)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)











share|improve this question
















I receive this error in crash report of just some users, but I don't understand it! The app works perfectly on almost all user devices!
This is not a duplicate question, because app works always, but crashes some times!



part of my code, shows the click is not something tricky:



fun grid_btn_clicked(v: View) {
showData(findJson(K1)!!)
}


and this is exception:




Fatal Exception: java.lang.IllegalStateException: Could not execute
method for android:onClick
at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
at android.view.View.performClick(View.java:5716)
at android.widget.TextView.performClick(TextView.java:10926)
at android.view.View$PerformClick.run(View.java:22596)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)








android exception onclick illegalstateexception






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 5:21







AVEbrahimi

















asked Nov 13 '18 at 5:13









AVEbrahimiAVEbrahimi

5,23184394




5,23184394








  • 1





    can you add some piece of code where its crashing ?

    – Faiz Mir
    Nov 13 '18 at 5:16











  • Please put showData function body. Most probably there is a null in some cases as u use !!, maybe try wrapping it with let to get secured from crashes

    – P.Juni
    Nov 13 '18 at 5:31













  • If there was problem in showData why exception raised here?!

    – AVEbrahimi
    Nov 13 '18 at 5:31











  • Dont really know because there is No code for other functions but if findJson can return null then u can get null in showData and in onClick

    – P.Juni
    Nov 13 '18 at 5:35






  • 1





    how have you set the click listener? If in the xml, then show the xml

    – Vladyslav Matviienko
    Nov 13 '18 at 5:39














  • 1





    can you add some piece of code where its crashing ?

    – Faiz Mir
    Nov 13 '18 at 5:16











  • Please put showData function body. Most probably there is a null in some cases as u use !!, maybe try wrapping it with let to get secured from crashes

    – P.Juni
    Nov 13 '18 at 5:31













  • If there was problem in showData why exception raised here?!

    – AVEbrahimi
    Nov 13 '18 at 5:31











  • Dont really know because there is No code for other functions but if findJson can return null then u can get null in showData and in onClick

    – P.Juni
    Nov 13 '18 at 5:35






  • 1





    how have you set the click listener? If in the xml, then show the xml

    – Vladyslav Matviienko
    Nov 13 '18 at 5:39








1




1





can you add some piece of code where its crashing ?

– Faiz Mir
Nov 13 '18 at 5:16





can you add some piece of code where its crashing ?

– Faiz Mir
Nov 13 '18 at 5:16













Please put showData function body. Most probably there is a null in some cases as u use !!, maybe try wrapping it with let to get secured from crashes

– P.Juni
Nov 13 '18 at 5:31







Please put showData function body. Most probably there is a null in some cases as u use !!, maybe try wrapping it with let to get secured from crashes

– P.Juni
Nov 13 '18 at 5:31















If there was problem in showData why exception raised here?!

– AVEbrahimi
Nov 13 '18 at 5:31





If there was problem in showData why exception raised here?!

– AVEbrahimi
Nov 13 '18 at 5:31













Dont really know because there is No code for other functions but if findJson can return null then u can get null in showData and in onClick

– P.Juni
Nov 13 '18 at 5:35





Dont really know because there is No code for other functions but if findJson can return null then u can get null in showData and in onClick

– P.Juni
Nov 13 '18 at 5:35




1




1





how have you set the click listener? If in the xml, then show the xml

– Vladyslav Matviienko
Nov 13 '18 at 5:39





how have you set the click listener? If in the xml, then show the xml

– Vladyslav Matviienko
Nov 13 '18 at 5:39












1 Answer
1






active

oldest

votes


















0














May b you are getting null value .Try putting your code under let and check while debugging that Are u gettingnull data from findJson(k1).



fun grid_btn_clicked(v: View) {
findJson(k1).let{
showData(it)
}
}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274227%2fjava-lang-illegalstateexceptioncould-not-execute-method-for-androidonclick%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    May b you are getting null value .Try putting your code under let and check while debugging that Are u gettingnull data from findJson(k1).



    fun grid_btn_clicked(v: View) {
    findJson(k1).let{
    showData(it)
    }
    }





    share|improve this answer




























      0














      May b you are getting null value .Try putting your code under let and check while debugging that Are u gettingnull data from findJson(k1).



      fun grid_btn_clicked(v: View) {
      findJson(k1).let{
      showData(it)
      }
      }





      share|improve this answer


























        0












        0








        0







        May b you are getting null value .Try putting your code under let and check while debugging that Are u gettingnull data from findJson(k1).



        fun grid_btn_clicked(v: View) {
        findJson(k1).let{
        showData(it)
        }
        }





        share|improve this answer













        May b you are getting null value .Try putting your code under let and check while debugging that Are u gettingnull data from findJson(k1).



        fun grid_btn_clicked(v: View) {
        findJson(k1).let{
        showData(it)
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 6:11









        Android GeekAndroid Geek

        187112




        187112






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274227%2fjava-lang-illegalstateexceptioncould-not-execute-method-for-androidonclick%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Coverage of Google Street View

            Full-time equivalent

            Surfing