Solved

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

Posted on 2011-03-14
2
2,199 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction Everyone is using a smartphone these days. Contacts, messages, applications, documents, bookmarks, pictures, videos and other stuff which you created and are present only on your device come under the umbrella called “Personal Data”.…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

23 Experts available now in Live!

Get 1:1 Help Now