Rafael T Rafael T - 5 months ago 8
Android Question

Android, string resource not found

I'm working on an App, and I am getting weired errors. I put in some String resource in

res/values/strings
and saved it. Now If I want to access it in an Activity I get an error like this

07-13 11:16:20.050: ERROR/AndroidRuntime(5883): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f060006


And I can't figure out why.
Resource looks like this:

<string name="dialog_download_text">please wait while downloading</string>


and I want to Access it like

public void onCreate(Bundle b){
super.onCreate(b);
String s = getResources().getString(R.string.dialog_download_text);
}


I also looked into R.java and found my Entry

public static final class string {
public static final int dialog_download_cancel=0x7f060005;
public static final int dialog_download_text=0x7f060007;
public static final int dialog_download_title=0x7f060006;
}


I don't know what to do, because I never had a problem like this before.
Please help me. Thanks all.

Answer

Sometimes I get this error (once every 2 days), and it's because eclipse is not compiling the new code and it's deploying the old apk. I fix this by

  • doing a clean on eclipse (Project -> clean)
  • closing the emulator
  • restarting the adb server by running adb kill-server and adb start-server from the command line