This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Android and the fly likes R cannot be resolved to a variable , syntax errors in program that was working fine day before Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Mobile » Android
Bookmark "R cannot be resolved to a variable , syntax errors in program that was working fine day before " Watch "R cannot be resolved to a variable , syntax errors in program that was working fine day before " New topic
Author

R cannot be resolved to a variable , syntax errors in program that was working fine day before

Sam Acropolis
Greenhorn

Joined: Sep 30, 2012
Posts: 16
Line 15 and 22 complain that
R cannot be resolved to a variable


I have tried removing the

statement and even renaming it to import com.HelloWorld.firstandroidproject.R;

but the syntax errors still persist ...

any ideas?


Thanks a bunch everyone


Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42954
    
  73
You should not have to import anything, it should just work - how are you building the project? The R.java (and R.class) files are generated automatically, and part of the package that's listed in AndroidManifest.xml - which in your case should be "com.example.firstandroidproject", not "com.HelloWorld.firstandroidproject".
Sam Acropolis
Greenhorn

Joined: Sep 30, 2012
Posts: 16
My package name is as you say it com.example.firstandroidproject;

Im pretty much creating a android virtual device and then attempting to launch it , I have even tried 'cleaning' the project to from the 'project' menu in eclipse.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: R cannot be resolved to a variable , syntax errors in program that was working fine day before