![]() | 3.8 R cannot be resolved |
|
16 Mar 2011, 00:11
Wil Haywood (3 posts) |
Hi all, I have looked over this code endlessly. There are numerous suggestions here that i have employed, including a ‘clean’.. but I cannot get past the variable issue. The code worked wonderfully until I constructed the menu. Any thoughts? |
|
16 Mar 2011, 04:44
Wil Haywood (3 posts) |
Suduko.java package org.example.sudoku; import android.app.Activity; import android.os.Bundle; import android.view.Menu; public class Sudoku extends Activity implements OnClickListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
|
|
16 Mar 2011, 14:50
Anthony Shaw (115 posts) |
It sounds like the resources are not being built, so maybe there is a problem in res\layout\main.xml or res\layout-land\main.xml or res\xml\settings.xml. Open each one in the Eclipse editor and see if there are any warning messages in them. |
|
17 Mar 2011, 01:20
Ed Burnette (1316 posts) |
Also look in the Problems and Console views in Eclipse. Usually an “R cannot be resolved” error is caused by a typo in the XML. Here’s some email I sent another reader today who was having the same problem. It shows the diagnostic process you need to go through to find the error: “[After loading the code in Eclipse] I noticed this error in the Problems view:
That told me to look at the Console view where I found errors like this:
That told me there must be something wrong in the string definitions and to look at the res/values/strings.xml file, where I found a syntax error. This section:
has the starting string element for about_text in the wrong place. It should be moved down like this:
In XML, every starting element like “ |
|
20 Mar 2011, 18:14
Wil Haywood (3 posts) |
Thanks, Ed.. There was something out of place on another string element. Great suggestions… |
|
21 Mar 2011, 00:00
Pfeffa-rah (1 post) |
Hi there, I ran into the same problem. All strings seem to be allright. They are all there and all tags are nicely closed etc. The console just tells me this: (the W/ResourceType number changes…) I checked my menu.xml several times, and since there are only a few lines there, its was easy enough. ... The errors were gone and left me completely baffled…. Any ideas what I went wrong? greetz, |
|
21 Mar 2011, 19:41
Mike Puckett (1 post) |
I had the same problems. Basically, R.java wasn’t getting populated. I found that, in order to fix it, I had to move the to the end. Perhaps, because the about_text is so long, XML was having trouble parsing the rest of the values.xml file correctly? |
|
22 Mar 2011, 01:05
Ed Burnette (1316 posts) |
Some typos are very hard to see, especially when you’re not 100% confident that they’re really there. Changing a colon (:) to a period (.) is only a matter of a couple of pixels on the screen, for example. And just to keep things interesting there’s always the remote possibility that somehow an invisible unprintable character snuck in to spoil your day. (Show whitespace can sometimes help with those, as can 3rd party editors with hex modes). Matching up opening and closing tags in both XML and Java always gets me. Luckily the Format command (Ctrl+Shift+F in most editors) helps with that particular problem. |
| You must be logged in to comment |

