Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resources NotFoundException?

Tags:

android

I'm getting crash reports from android marketplace:

android.content.res.Resources$NotFoundException: Resource ID #0x.... 

I get about 17 of these a week. It's pointing me to the following in my code:

context.getResources().getDrawable(R.drawable.foo); 

That resource is definitely present in my /drawable folder. I have several hundred thousand installs, I'm not sure how this could be failing for some users, but working for the vast majority. I'd like to find out what's going on, because they can't use the app in this state. Any ideas?

Thanks

--------- Update ----------------------

Also I can see the entry for the drawable in question in my R.java file, looks like:

public static final int foo=0x7f020034; 

I do a clean build of the project, then straight after that do my release build (no code modification in between to give the automatic eclipse build stuff possibly let the R file go awry)

Thanks

like image 707
user291701 Avatar asked Feb 27 '12 16:02

user291701


Video Answer


2 Answers

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)); 
like image 89
live-love Avatar answered Oct 04 '22 12:10

live-love


Is the crash reports coming from version <=1.6, and you have certain resources only in qualified folders, i.e. "drawable-mdpi" instead of just "drawable"? If so then read about "Known issues" at the bottom of this page.

like image 27
pgsandstrom Avatar answered Oct 04 '22 12:10

pgsandstrom