Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wireless Headphone with mike for web conference 4 68
Android Security Model 3 108
Need Help To Develop Android App 1 41
Details to create developer account 10 36
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
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…

770 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