Solved

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

Posted on 2011-03-14
2
2,224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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
free up ram on my Note 4 Galaxy Samsung 20 80
Delphi: barcode reading on android platform 1 99
How to export SQL to firebase ? 7 174
Hardware keyboards 11 97
Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.

734 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