Monday, 30 May 2011

Android runtime Error - android.content.res.Resources$NotFoundException

Sometimes I find this exception:

05-30 23:14:09.869: ERROR/AndroidRuntime(9255): android.content.res.Resources$NotFoundException: String resource ID #0x7f04004b
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at android.content.res.Resources.getText(Resources.java:200)
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at android.content.res.Resources.getString(Resources.java:253)
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at android.content.Context.getString(Context.java:149)
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at *.java:671)
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at *.java:299)
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at *$1.run(*.java:2175)
05-30 23:14:09.869: ERROR/AndroidRuntime(9255):     at java.lang.Thread.run(Thread.java:1102)


It seems the application cannot find the proper String in the R file. This is a runtime error, which means the code is syntactically and semantically (Also lexically) correct, but something bad happened when the application is running. In this case, resource not found.

One way to solve this problem is try to regenerate the R file. To do it
1. Press on Project -> Clean...
2. Select the project and press Ok.

Maybe you are going to see this error:
[2011-05-30 23:12:13 - YouTubeMonitor] ERROR: Unable to open class file /Users/.../.../R.java: No such file or directory
This is absolutely normal, because it has been removed.
Wait few seconds and it will be generated automatically.

1 comment:

  1. Anonymous said...

    How to find if this exception is generate in you live application

    ReplyDelete