Solved

Android classpath problem? --R cannot be resolved to a variable

Posted on 2011-03-14
2
2,205 Views
Last Modified: 2012-05-11
I have created a new android project in Eclipse helios and I get an error in the autogenerated calss file, Eclipse gives an error:

'R cannot be resolved to a variable'

I have been googling for a solution but cannot find one, any suggestions?

I have added the java, layout and manifest as a code snippet and a screenshot of the buildpath in eclipse.

Tks,
Owen.

 Libraries in use
package map.googlemaps;


import com.google.android.maps.MapView;
import android.os.Bundle;
import com.google.android.maps.MapActivity;

	

public class MapsActivity extends MapActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main); // error here
    }
    @Override
    protected boolean isRouteDisplayed(){
    	return false;
    }
}

main.xml->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
		android:layout_width="fill_parent"
		android:layout_height="fill_parent">
		
		<com.google.android.maps.MapView
			android:id="@+id/mapview"
			android:layout_width="fill_parent"
			android:layout_height="fill_parent"
			android:enabled="true"
			android:clickable="true"
			android:apiKey="0QIYhVPOyQRjaBNI0fNbk9vavLvlAs4F-nT90pg"
			/>
		</RelativeLayout>

-> Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="ask.map"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps" />
        <activity android:name=".MapsActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-permission android:name="android.permission.INTERNET" />


</manifest>

Open in new window

0
Comment
Question by:OwenMoriarty
2 Comments
 
LVL 17

Accepted Solution

by:
Dejan Pažin earned 500 total points
ID: 35131691

R is a generated class. All you have to do, is have it in your classpath of the project.

I dont work with Eclipse, so I cant really tell you how to add that to the classpaht, but it should be very simple.

If you are just starting out, you might give IntelliJ IDEA a try - the new version has a free community edition with Android support built in. With IDEA the wizard for building a basic Android application will do all this stuff for you.

I guess Eclipse should have done that also, but you might have taken a wrong turn at some step.
0
 

Author Closing Comment

by:OwenMoriarty
ID: 35481889
Awarding points to close the question, I don't have time to look at this now,
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now