سؤال

I'm writing on a custom view in android. It uses some png's, provided as resources in the drawable-folder (I put it in all of the drawable folders now, just to make sure) of my project.

Unfortunately, when I startup the app, I get a force close and the last thing the log says is: "WARN/ResourceType(261): Resources don't contain package for resource number 0x7f020002" (The Hex-Number is the first icon I intend to load).

Now for the curious thing: The graphical layout-editor of the eclipse adt plugin has no problems whatsoever loading an displaying the icons in its design view. It's only when I start up the actual app (emulator or actual cellphone), that android can't find the resources.

I tried cleaning the project and refreshing the file structure. That didn't quite work out -.-

EDIT: I just realized that I can't even load a string resource. The problem seems to exist for all resources. Do I have to do something, before the resources become available?

Hope someone can help me,

thx in advance

هل كانت مفيدة؟

المحلول 2

kk, this year's dumbness awards go to me. I was using Resources.getSystem().get... instead of this.getContext().getResources().get...

thx to all of you for your help

نصائح أخرى

Some times when adding resource files to res dir, the generated R class gets out of sync with its assets. If you are compiling on the command line with ant, try navigating to where build scripts are and doing a clean build:

ant clean

I don't really know much about eclipse, but there might be a way to tell eclipse to refresh generated files.

I had the same issue in v2.1 Emulator, while the same app runs smoothly in 1.5,1.6,2.3.x and 4.x AVDs.

I am using library in my project.The resource number was not even in R.java file. So, ultimately I found that the resource id was in some other package's R file, which had no relation to my project. After deleting this project and Cleaning the projects, my app loaded smoothly :)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top