0

I am trying to compile my android app that I am crating by following the google tutorial at https://developer.android.com/training/index.html

I have run into a problem where I get the error "R cannot be resolved to a variable"

I followed the suggestions from the other threads such as cleaning/rebuiding, removing all import android.R, and reinstalling my Android SDK Build-tools for every version

Here is a copy of the tutorial project with the issue MyFirstApp.zip

I have taken the suggestions found in other threads, but their solutions have been unsuccessful.1 2 3 4 Please help!

Please let me know if there is any other information you need to fix this issue.

Community
  • 1
  • 1
DSdavidDS
  • 153
  • 1
  • 2
  • 12
  • 1
    Are you using an IDE such as Eclipse? – mattbdean May 01 '14 at 23:24
  • Yes. Sorry for not specifying that. I am currently using the latest version of Eclipse. – DSdavidDS May 01 '14 at 23:26
  • Have you tried [this](http://stackoverflow.com/a/15761439/1275092)? – mattbdean May 01 '14 at 23:27
  • I just went down the list and I am sure that everything was covered. I don't have any XML errors (two warnings about grammar which shouldn't be a problem). [I would appreciate it if someone tried compiling the program on their own computer to see if they can recreate the error and make sure it is not a problem with my compiler] – DSdavidDS May 01 '14 at 23:36
  • In addition to @cjbrooks' answer, make sure there aren't any files in your resource directory that don't belong there. I've run into problems in the past (sometimes I edit files manually using an editor that leaves a backup copy of the file ending in `~` in the directory, and that has caused problems if I leave the backup file there). – ajb May 01 '14 at 23:43
  • You can see for yourself what is in my resource directory but there isn't anything obsolete that I don't need. Everything seems to be find as far as I know. – DSdavidDS May 01 '14 at 23:49

2 Answers2

2
I have seen your code there is an error inside main_activity_actions.xml which is inside your menu folder

It does not find @string/action_search which must be present in strings.xml

So put <string name="action_search">Search here</string> inside your strings.xml

and clean and build the project.

I hope the error will be solved.
Imran Betara
  • 649
  • 3
  • 8
  • Thank you so much! I can't believe I missed that. The tutorial kinda grazed over that part and I guess I was expected to cover that on my own. Thank you again for fixing this! – DSdavidDS May 02 '14 at 21:47
0

It usually append when you have an error with your XML file.
Maybe you try to use an XML variable who doesn't exist anymore. It will not give you any error on your XML.
Verify your XML variable on your file 'Value' and which you call from your Java file

Guillaume
  • 144
  • 2
  • 11