Resource ID not resolved


#1

I am trying out the first example and get errors in theQuizActivity.java file:

package com.bignerdranch.android.geoquiz;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class QuizActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quiz);<------------ "R" unknown
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.quiz, menu);<----------- "R" unknown
    return true;
}   

}

My activity_quiz.xml and strings.xml are per the book.

Any suggestions? This forum looks fairly inactive so I have some suspicions the others have the same problem or that people are simply reading the book and not running the code. I am running the most recent ADT (Build: v21.1.0-569685)


#2

Have you changed the R.java file?


#3

Nope. No changes to any generated files.


#4

That means that your R.java file is not being generated.

  1. Try to clean your project (project->clean) and rebuild it.

  2. if not worked, delete the folder gen in your project.

  3. you are not running the most recent ADT, if 1) and 2) didn’t work, download the bundle ADT 22 (latest build). After the download you can set the SDK Path so don’t need to download all the SDK Api’s/sources/other. After the update import your project into the new workspace. It’s a pain to do that, but works for me.

In my past experience that only occurred to me when i update the SDK. So i tried very processes to solve the issue and the only that really worked in most cases was the 3).


#5

Same problem here. Just bought the book yesterday and trying out the first project. As soon as I’ve configured the new activity and hit finish to create and open the new project, my gen folder is created empty. the SDK and ADT are fully updated, I’ve tried restarting everything, I’ve tried Project -> Clean, right clicking the project root and doing Android Tools -> Fix Project Properties, as well as deleting gen and rebuilding. Still nothing but an empty gen folder. :confused:

Anyone have any ideas?


#6

Ok, that was +/- unexpected. Try an answer in google official Android Developer site… google launches updates “everyday”, so they that can bring a lot of bugs, which appears to be the case. Good luck


#7

Same issue have checked every line of code, cleaned, have the most recent update, and still get this error. If anyone figures out a fix please post.


#8

I had the same problem. Leaving “action_settings” string as is instead of changing it to a “menu_settings” string seems to have solved the problem.
Check the thread: "menu_settings vs. action_settings in string resources ".


#9

I figured out the problem make sure you have the newest SDK Build-tools installed Rev. 17. I installed and restarted and the R files have returned. Thanks for the help to all who contributed.


#10

I’m still having the issue. Like I said all my stuff is up to date, and I don’t change any files. Literally as soon as I start a new Android Application the gen folder is created completely empty.

Please help!!