Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML files not being recognized/resolved - SOLVED!

 
Ryan Lemon
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've just done a fresh re-install/extract of Eclipse off Android's website, hardly added much code or XML to my project, yet nothing's being recognized outside of my MainActivity.java. And before you ask-yes, I've tried cleaning and restarting Eclipse. I've also tried moving out my Gen folder to let Eclipse generate another Gen folder, which generates another R.java file since that seems R.java seems to be connected with reference problems.

(see comments for where the errors are) For example, in the first method (onCreate), the second like there's activity_main that Eclipse is saying it can't resolve, as if it doesn't exist. Consequently, my CreateLG button in the onCreateLGClick method isn't resolved/recognized either. Neither is the main (.xml) or createlg_menu (.xml) resolved..

MainActivity.java:


Here's the other files in case you want to see them:

activity_main.xml:


createlg_menu.xml:


main.xml:
 
Ron McLeod
Bartender
Pie
Posts: 1042
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are layout.activity_main and menu.main present in the R.java file?
 
Ryan Lemon
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe so, unless I'm reading it wrong:
R.java:

 
Ron McLeod
Bartender
Pie
Posts: 1042
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, then you must be referencing the wrong R class. Remove this import: import android.R;
 
Ryan Lemon
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just tried, didn't work unfortunately. Doesn't make much sense.. especially since I just reinstalled Eclipse and only added one button, some code, and one xml file
 
Ron McLeod
Bartender
Pie
Posts: 1042
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Eclipse, hover-over the R and see what class it reports.



It should be com.example.groceryrunner.R
 
Ryan Lemon
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, doesn't say that:
 
Ron McLeod
Bartender
Pie
Posts: 1042
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I thought. You have to track-down where/how you are referencing android.R instead of com.example.groceryrunner.R. Check again to make sure you have removed the import for android.R.

You could also replace R.menu.main with com.example.groceryrunner.R.menu.main, but better to find where the reference to android.R is sneaking-in.
 
Ron McLeod
Bartender
Pie
Posts: 1042
65
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ryan - check PM.
 
Ryan Lemon
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MOTHERS OF NEPTUNE'S PEARLS you were right. I deleted the import again and commented out the lines that had the errors. Restarted Eclipse, Built All, and uncommented the code and wa-la! All's fine now! :Cyber-Five: Thanks for all the help, this errors been plaguing me for 2 days now, couldn't get anything done, now I can march on forth..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic