Search code examples
javaandroideclipser.java-file

Basic Android Project: alternating cannot be resolved or is not a field/R cannot be resolved into a variable errors


I am new to Android Development/Java Programming/Eclipse so please bear with me. I've been going through the Android Developer Training (developer.android.com/training) and the Hello Android book by Ed Burnette and keep running into a problem that is making it difficult to move forward. I'll do my best to describe it and am hoping that the community can help me resolve it.

I began seeing this issue with the Android Developer Training (around Adding the Action Bar -> Adding Action Buttons) and it became impossible to circumvent at Hello Android's 3.3 Creating Opening Screen when I tried adding the Sudoku buttons. The only change I made when going through Hello Android was adding the Android Development Toolkit (ADT) for Eclipse. I don't recall this being a required download going through the Android Developer Training page so I am wondering if its addition could have contributed to the problem.

The issue that I keep running into is that when I go to build the project, Eclipse keeps telling me:

action_settings cannot be resolved or is not a field

activity_sudoku cannot be resolved or is not a field

container cannot be resolved or is not a field

fragment_sudoku cannot be resolved or is not a field

sudoku cannot be resolved or is not a field

I've tried several fixes that I saw on in the forum including deleting the import.android.R from the sudoku.java file in my src folder but that brings up a bunch of errors that say R cannot be resolved into a variable. I've tried cleaning and rebuilding and restarting Eclipse, methods that occasionally worked before Hello Android and the plugin, but keep getting the same errors. I've also tried setting to Android 3.0 and higher thinking that might be an issue but there was no change. Occasionally I get another error regarding not being able to find the path for a container but I've been playing around with the IDE for 15 minutes and can't seem to get it to pop up again.

I could really use some help on this.

Hope to hear from you,

Yusif Nurizade


Solution

  • This solution may, first and foremost, demonastrate how green I am with Android programming but I believe I found the solution.

    Initially following the Android Developer Tutorial, I downloaded the latest versions - 18, 19, 20, etc. When I was creating the project, however, I was specifying much early versions for compatibility; all the way down to 7 or 8. I looked into this because I remembered seeing a message from the IDE regarding the Action Bar and how some commands weren't supported on Version X.

    I went back and downloaded all the versions down to 7 or 8 and set the compatibility accordingly. The example now works with minimal other changes. I realize that I may be overlooking something but this is the only major change I made and it seems to have done the trick.

    Hopefully this will help other newbies!

    Yusif Nurizade