1. Download our Official Android App: Forums for Android!

Apps Problem with an app , bug

Discussion in 'Android Development' started by jakobia, Jan 15, 2018.

  1. jakobia

    jakobia Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 26, 2017

    Nov 26, 2017
    7
    1
    6
    Hi, try to do this app from this youtube video: and I am at 1:27:59



    Then I click any button I got this error:

    008 12127-12127/se.jakobia.flagsquizapp E/AndroidRuntime: FATAL EXCEPTION: main Process: se.jakobia.flagsquizapp, PID: 12127 java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at se.jakobia.flagsquizapp.Playing.onClick(Playing.java:136) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 01-11 12:08:36.228 12127-12127/se.jakobia.flagsquizapp I/Process: Sending signal. PID: 12127 SIG: 9

    this line of code is a problem:

    txtScore.setText(String.format("%d",score));

    There should I start?
     

    Advertisement

  2. LV426

    LV426 I say we take off and nuke this place from orbit
    Recognized Developer
    Rank:
     #12
    Points:
    1,988
    Posts:
    9,180
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    9,180
    13,678
    1,988
    Male
    Software developer
    South West of England
    Variable txtScore is null. Do you understand what that means?

    If you show the code you're using we could get a better picture of what's going wrong.
     
  3. jakobia

    jakobia Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 26, 2017

    Nov 26, 2017
    7
    1
    6
    I tried to export the whole project to a zip file.
     

    Attached Files:

  4. jakobia

    jakobia Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 26, 2017

    Nov 26, 2017
    7
    1
    6
    I suspect the error is in this lines of codes

    "
    public void onClick(View v) {

    mCountDown.cancel();
    if(index < totalQuestion) {
    Button clickedButton = (Button)v;
    if(clickedButton.getText().equals(questionPlay.get(index).getCorrectAnswer()))
    {
    score+=10;
    correctAnswer++;
    showQuestion(++index);
    }
    else
    showQuestion(++index);
    txtScore.setText(String.format("%d",score));
    }

    }
     
  5. jakobia

    jakobia Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 26, 2017

    Nov 26, 2017
    7
    1
    6
    I have solved the problem from help from a facebook group.
     

Share This Page

Loading...