Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android Box Xibo software 3 134
Need Help To Develop Android App 1 43
Android app that calculates age from calendar and facebook 3 57
moto 4g plus memory usage 30 45
First off, some of you reading this are already thinking there is an error in the title. It really should be Kindle Fire versus OTHER Android tablets. That's because the Amazon Kindle Fire IS an Android tablet. Well, it is and it's not. It's running…
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 …
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.
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…

840 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