I\'m getting crash reports from android marketplace:
android.content.res.Resources$NotFoundException: Resource ID #0x....
I get about 17 of
The same problem I found on my application today morning and found a very simple solution to this. the problem looks big and complicated but it's not.
Steps which I followed are
According to me it should not give this exception again.
Reason : When you build the application R.java contains all the memory address and it happens that those address are invalid for next run.
Second Reason : When you have the application which supports lanscape and portrati mode both and if you have not wrote the XML file for either of them then it's the possibility that may lead to this kind of crash. and there are pretty much chances of OutoFmemory and Memory leak issues when you have to support both the modes. please think on this as well.
I got this exception:
Resources$NotFoundException: String resource ID
when I was using setText with an int value. I had to convert it to String.
Before:
myTextView.setText(obj.SomeIntProperty);
After:
myTextView.setText(String.valueOf(obj.SomeIntProperty));
In my case I had a layout file that lead to the crash:
I got the following log-
That showed this link to my actual code:
Which is this line of code:
I checked my file navigator folder names as suggested by the most popular answer and it looked like the resource that is supposedly missing is in the normal layout
folder
but when looking under the Project
file navigator rather than the Android
file navigator I was able to see that not only was the supposedly missing resource file not in the normal layout
folder, but I didn't even have a layout
folder without a special extension.
Adding an Android Resource Directory to the res
folder and calling it layout
and then pasting over the resources from your speciality folder (ex. layout-sw720dp
) into it fixed the issue for me.
This solution will also work for other folders as suggested such as not having files in drawable
and only having them in drawable-xxhdpi
can be fixed by moving the file into drawable
and tweaking it as needed. Good luck folder fiends!
The error can happen when portrait XML layout file is not defined. It doesn't happen all the time, but happens for example if user quickly turns off and on the phone, I suppose in that case the system calls the onCreate in portrait orientation, before calling onCreate in landscape.