Today I was debugging my android app and it crashes. Here is the call stack:
android.content.res.Resources$NotFoundException: String resource ID #0x8822
at android.content.res.Resources.getText(Resources.java:246)
at android.widget.TextView.setText(TextView.java:3860)
at com.whackanandroid.GameActivity.gameOver(GameActivity.java:68)
at com.whackanandroid.Game$1.onCountDownFinished(Game.java:79)
at com.whackanandroid.CountDown$1.run(CountDown.java:23)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
Then I clicked on the line number links (TextView.java:3860) and it took me to a line of javadoc comment. I was really confused. Comments never get executed. That can't be wrong. This is strange.
Here is my code:
public void gameOver () {
tvScore.setText (Integer.toString (Game.getInstance ().getScore ()));
tvHighscore.setText (Game.getInstance ().getHighscore ());
tvScoreText.setVisibility (View.VISIBLE);
tvScore.setVisibility (View.VISIBLE);
Animation anim = AnimationUtils.loadAnimation (this, R.anim.cover_fade_in);
anim.setAnimationListener (new Animation.AnimationListener () {
@Override
public void onAnimationStart(Animation animation) {
GameActivity.this.cover.setVisibility (View.VISIBLE);
}
@Override
public void onAnimationEnd(Animation animation) {
GameActivity.this.cover.setVisibility (View.VISIBLE);
Game.InitializeGame (GameActivity.this);
cover.setVisibility (View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
cover.startAnimation (anim);
}
The line tvHighscore.setText (Game.getInstance ().getHighscore ());
refers to the line in the call stack: at com.whackanandroid.GameActivity.gameOver(GameActivity.java:68)
. I think it might be because tvHighscore's parent view, a LinearLayout
is GONE
. Does this matter? Or did I do anything else wrong?
If you need to see more code, feel free to ask me.