开发者

Trouble adding raw resource

I'm walking through a small example to hit https web services. It requires building a keystore and placing the resulting bks file into the /res/raw directory. Simple enough. However, I can not access the file through R.raw...

I placed the file into the /res/raw directory, refreshed my project in Eclipse, navigated to the /res开发者_运维技巧/raw directory in Eclipse and confirmed that it showed up in the project. However, when I type R.raw. in my file, the resulting list of possible filenames is empty.

I've tried cleaning and rebuilding, but the project still has no clue what R.raw.mycert is.

What am I doing wrong?


The answer to this question can be found here:

R.raw.anything cannot be resolved


When Eclispe is starting to behave weirdly, my last trick is to remove the project from the workspace and add it again... Try also to quit and restart eclispe

Good luck!


Try this -- find your EclipseWorkspace. There should be a 'res' directory. So open it. You will likely NOT find a 'raw' subdirectory.
So create a 'raw' directory, and drop your file into it. (I suppose these have to follow the rwx permissions under Linux that the others follow. I did this in Windows.) Close the project, then open it again. See if 'res.raw.yourfile' shows up in the package explorer (it should). I also discovered that 'R.raw.yourfile' is now noticed, and you should find an entry in 'gen/*/R.java' for this.

I think there's a bug in the gen compiler, or maybe Eclipse configuration. gen seems to be very picky about just what kind of resource it wants to look at, and is also doing some name mashing. For example, R.string.xxx finds a string by name xxx, even though the string resources are under 'res.values.string.xml'. So there's clearly a lot of magic going on, maybe special kludges known only to the gods in Mountain View.

Why this fix broke it loose I have no idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜