Unraveling a user submitted stacktrace, MediaPlayer null pointer?
<p>I have my first application up on the market and I have been liking the statistics so far. I got my first bug report which gave me the stack trace and a small description. I used the retrace tool and the trace looks like this:</p>

<pre><code>java.lang.NullPointerException
at app.koreanstudy.Alphabet.java.lang.String getNext()(Unknown Source)
                            void play(android.content.Context)
at app.koreanstudy.AlphabetActivity.void onClick(android.view.View)(Unknown Source)
</code></pre>

<p>I can't quite tell where this NullPointerEx is coming from.. I guess the play() method due to the user's description of the problem. </p>

<p>This is my play method:</p>

<pre><code>    public void play(Context context){
    if (soundPlayer != null){
        soundPlayer.release();
    }

    int rId = 0;

    switch(aIndex){
        case 0: rId = R.raw.c0; break;
        case 1: rId = R.raw.c1; break;
        case 2: rId = R.raw.c2; break;
        case 3: rId = R.raw.c3; break;
        case 4: rId = R.raw.c4; break;
        case 5: rId = R.raw.c5; break;
        case 6: rId = R.raw.c6; break;
        case 7: rId = R.raw.c7; break;
        case 8: rId = R.raw.c8; break;
        case 9: rId = R.raw.c9; break;
        case 10: rId = R.raw.c10; break;
        case 11: rId = R.raw.c11; break;
        case 12: rId = R.raw.c12; break;
        case 13: rId = R.raw.c13; break;
        case 14: rId = R.raw.v14; break;
        case 15: rId = R.raw.v15; break;
        case 16: rId = R.raw.v16; break;
        case 17: rId = R.raw.v17; break;
        case 18: rId = R.raw.v18; break;
        case 19: rId = R.raw.v19; break;
        case 20: rId = R.raw.v20; break;
        case 21: rId = R.raw.v21; break;
        case 22: rId = R.raw.v22; break;
        case 23: rId = R.raw.v23; break;

        default: rId = R.raw.error; break;
    }

    soundPlayer = MediaPlayer.create(context, rId);
    soundPlayer.start();
}
}
</code></pre>

<p>If the error is indeed here I guess it's from not checking the MediaPlayer returns NULL? </p>

<pre><code>    soundPlayer = MediaPlayer.create(context, rId);
    // should check if it's null here?
    soundPlayer.start();
</code></pre>

<p>However, I am unsure why this would be a problem? The user is on a Verizon Droidx2 if that helps. </p>

<p>For completion (and the null ptr says java.lang..)</p>

<pre><code>    public String getNext(){    
    /*
     * If the current index is at the end, don't increment aIndex. Instead,
     * return the final character of the alphabet. 
     */
    return aIndex == 23 ? aList.get(aIndex) : aList.get(++aIndex);
}
</code></pre>
