Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » invalid reference to 'R' object in new project (Juno with Android 2.1 sdk installed on Ubuntu 12.04)
invalid reference to 'R' object in new project [message #957935] Thu, 25 October 2012 12:05 Go to next message
Ruud Naastepad is currently offline Ruud Naastepad
Messages: 2
Registered: October 2012
Junior Member
I just installed Eclipse Juno with Android 2.1 SDK on an Ubuntu 12.04 system with Java 1.6.0_35 JDK.

When I create a new Android Application project a source file MainActiviy.java is created automatically with reference to an object named 'R'. Eclipse reports an error there: 'R cannot be resolved to a variable'. If I right click on R looking for its declaration I get error 'the source attachment does not contain the source for the file R.class. Then it says you can change the source attachment by clicking change attached source. When I do so and point the the file android.jar that contains the source code it still doesn't show.

What is wrong?

(I had Eclipse with the same configuration installed under Windows and there this problem didn't arise (right clicking on R shows the sourcecode for class R and no error is reported in the first place about R.)
Re: invalid reference to 'R' object in new project [message #959164 is a reply to message #957935] Fri, 26 October 2012 09:53 Go to previous messageGo to next message
Russell Bateman is currently offline Russell Bateman
Messages: 3125
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 10/26/2012 07:42 AM, Ruud Naastepad wrote:
> I just installed Eclipse Juno with Android 2.1 SDK on an Ubuntu 12.04
> system with Java 1.6.0_35 JDK.
>
> When I create a new Android Application project a source file
> MainActiviy.java is created automatically with reference to an object
> named 'R'. Eclipse reports an error there: 'R cannot be resolved to a
> variable'. If I right click on R looking for its declaration I get error
> 'the source attachment does not contain the source for the file R.class.
> Then it says you can change the source attachment by clicking change
> attached source. When I do so and point the the file android.jar that
> contains the source code it still doesn't show.
>
> What is wrong?
>
> (I had Eclipse with the same configuration installed under Windows and
> there this problem didn't arise (right clicking on R shows the
> sourcecode for class R and no error is reported in the first place about
> R.)


http://www.eclipse.org/forums/index.php/t/225513/

http://www.javahotchocolate.com/tutorials/android.html#r-java

Best of luck.
Re: invalid reference to 'R' object in new project [message #959494 is a reply to message #959164] Fri, 26 October 2012 15:14 Go to previous message
Ruud Naastepad is currently offline Ruud Naastepad
Messages: 2
Registered: October 2012
Junior Member
Thanks. Actually the problem was not an Android problem but was solved by following the instructions from message #509484. To my surprise I may say since I followed detailed instructions (wiki.ubuntuusers.de/Java/Installation/Oracle_Java?redirect=no) to do a clean install of Java 1.6 JDK after uninstalling the OpenJDK. However Eclipse apparently still managed to find a reference to the wrong JDK...
Previous Topic:start tomcat in eclipse ...
Next Topic:how to install patch for HTTP preview on mac
Goto Forum:
  


Current Time: Sat Jul 26 09:18:42 EDT 2014

Powered by FUDForum. Page generated in 0.02094 seconds