Resource IDs not generating in R.java


#1

Hi,
As mentioned in Listing 1.6 ,I have added IDs in activity_quiz.xml but same is not getting reflected in R.java as shown in Listing 1.7 .What am I missing?I tried to clean up using Project>Clean but it also did not help.

Thanks


#2

Verify that all of your activity_quiz.xml and QuizActivity.java is correct. shift-ctrl-o on QuizActivity.java to ensure that your imports are correct. If all else fails, do a clean which will remove the gen directory. The directory will be rebuilt again.

I’ve had this issue when I misspell something in my .xml files which then causes and error. Make sure all errors are resolved.


#3

Maybe its too late, but I will post my answer for other people. I had the same problem. It wasted one whole day to figure out what was wrong.

My symptom was the same: R.java was not updated. I followed everything what this book asked. I also search this forum and googled it. I did “clean -> project” and “fix the project properties”. Nothing worked. I created and deleted GeoQuiz project at least 10 times. Never worked.

How did I solve?
It was simple. I deleted ADK folder, and re-downloaded and re-installed ADK. Then? It started to work at the first trial!! What the… :cry:
Anyway, if someone has the same error, delete your Eclipse & ADK directory, re-download it and re-install it. Don’t waste your day like me. :sunglasses:


#4

Hey,
Having same trouble with findViewById(R.id.). I’ve cleaned, checked my code over and over… no spelling errors used code assist as much as possible. Looking at the R.Java file all the buttons are listed but in QuizActivity.java the findViewById finds by next_button but not the true_button and the False_button. New to Android but not to programming, C, C++, VHDL, Java.
thanks


#5

Hey,
Me again… I have 3 R.java files. one under appcompat_v7 and 2 under GeoQuiz android.support.v7compat and one under my geoquiz directory…that can’t be good.
These are all auto generated files but when you are trying to link stuff to them sounds like trouble to me. I think I’m going to do what one member suggested and delete Eclipse (dang) and re-install maybe I picked up extra “support” I don’t need.
Any ideas?
Thanks


#6

I have R.java under android support v7 app compat (which I believe I got from installing the support library)

I have R.java under com.bignerdranch.android.geoquiz inside the gen folder.

It seems to work for me like this, all ID’s showing up in the R.java file and references working. I wonder what we did differently.

Mine show up in the the latter of the 2 R files under:
public static final class id {
public static final int true_button=0x7f05003c;
public static final int false_button=0x7f05003d;

}


#7

I also had this problem, and downloading and reinstalling the ADT bundle worked for me too.

Incidentally, I’m using Windows 7 and also updated my JDK at the same time; maybe that’s related. Thanks to kemjin for posting a suggested fix!