开发者

Error using eclipse for Android - No resource found that matches the given name

Common problem I'm sure, but I can't figure it out. In my AndroidManifest.xml and main.xml I'm getting the no resource found that matches the given name. I've double checked for typos and it used to work, but now I'm popping up with all these errors saying it can't find my strings in my strings.xml.

These are the ones I'm getting errors for in my main.xml.

    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dip"
    android:text="@string/instructions"    />

    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dip"
    android:text="@string/level_prompt"    />

    <Spinner         
    android:id="@+id/spinner"        
    android:layout_width="fill_parent"        
    android:layout_height="wrap_content"        
    android:prompt="@string/level_array"    />

These are the ones I'm getting for my androidmanifest.xml.

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloFormStuff" android:label="@string/title">

This is what my strings.xml looks like.

<string name="title">Title</string>
<string name="app_name">Application name</string>

<string name="instructions">Enter instructions here.</string>

<string name="level_prompt">Choose an item</string>

<string-array name="level_array">        
<item>Item On开发者_如何学JAVAe</item>        
<item>Item Two</item>        
<item>Item Three</item>        
<item>Item Four</item>
</string-array>

Any ideas? Any help would be appreciated!!


Accidentally moved the "values" folder outside of the "res" folder. Moved it back and it fired up!


This problem appeared for me due to an error in an XML layout file. By changing @id/meid to @+id/meid (note the plus), I got it to work. If not, sometimes you just gotta go to Project -> Clean...


I resolved this kind of issue like this: I went into my XML layout file, cut the line of code that was generating the error. Then I saved the file, and pasted the code back in. The error was gone.


One general solution to such tiny errors is that you close eclipse and start is again.. 3 irritating problems were solved.. its the problem with eclipse.. some times it didn resolve "R.id", the it didn find @string/somebutton, and then again some random thing... if nothing logical comes in your mind, try this, n conjure d result.. :)


I think the issue is that you have

android:prompt="@string/level_array"

and you don't have any string with the id, to refer to the array, you need to use @array

test this or put a screen of your log please


tried what KennyH write but it didn't solved my problem that appear while trying edit style.xml file in my android app, so I just delete the project from eclipse (not from disk of course !!) and import it back ,solved it for me in that case.


I renamed the file in res/values "strings.xml" to "string.xml" (no 's' on the end), cleaned and rebuilt without error.


I actually has this problem once with a path issue referring another project :

I had this in my default.properties:

android.library.reference.1=..\\MyProject_Core\\

Which I fixed like this:

android.library.reference.1=../MyProject_Core/

My colleague created the above with Windows but only the version below worked on my Mac.


If you are an iPhone Developer don't just add your picture (by right clicking then add file...like we do in iPhone). You have to copy and paste the picture in your drawable folder.


For me the issue appeared because my string file could not be parsed. I wanted to have a value like '%s - %s'. However this appeared to be triggering a problem, it seems string will try to parse this value in a special way. Because two string values were provided in a single value an error was written in the console, but I had so many errors triggered from that, that the initial error was hidden, because of small console buffer. Adding formatted="false" attribute to this string value of mine fixed the problem in the string file (which btw was not reported as compilation error in the file itself) and I was able to build once more.


Project ---> Clean does the trick in most of the cases. It did in mine.


Eclipse doesn't seem to like imported programs. What worked for me is renaming strings.xml to string.xml, save (without error) and then rename it back to strings.xml, save again and error doesn't show up again.

Eclipse would be sooo good if it wasn't for those tiny little errors all the time :(


I had the same issue and tried most of the solutions mentioned above and they did not fix it.. At then end, I went to my .csproj file and viewed it in the text editor, I found that my xml file that I put in the /Drawable was not set to be AndroidResouces it was just of type Content.

Changing that to be of type AndroidResouces fixed the issue for me.


Yet another Googlemare Landmine....

I solved this same problem today: Somehow, if you mess up, the icon line on your .gen file dies. (Empirical proof of mine after struggling 2 hours)

Insert a new icon 72x72 icon on the hdpi folder with a different name from the original, and update the name on the manifest also.

The icon somehow resurrects on the Gen file and voila!! time to move on.


I had problem with puuting background image. Error was the same. But I solved it by removing extension of file

android:background="@drawable/sky.png" --->> android:background="@drawable/sky"

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜