0

I'm trying to follow the tutorial here

And I'm getting this error saying R cannot be resolved. I cannot figure out how to import R. I presume I must have an error in my XML somewhere but am not sure.

Here I got this error: Element type "uses-feature" must be followed by either attribute specifications, ">" or "/>".

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.dublindrinkdeals"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="17" />
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <!-- Required to show current location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 
    **<!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />**

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.dublindrinkdeals.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- Google Maps API Key -->
<meta-data
     android:name="com.example.dublindrinkdeals.v2.API_KEY"
     android:value="APIKEY" />


    </application>

</manifest>

Here's my XML file:

<?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" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

Here's my java file. I'm getting the r error here twice for both occurrences

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MainActivity extends Activity {

    // Google Map
    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        **setContentView(R.layout.activity_main);**

        try {
            // Loading map
            initilizeMap();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * function to load map. If map is not created it will create it for you
     * */
    private void initilizeMap() {
        if (googleMap == null) {
            googleMap = ((MapFragment) getFragmentManager().findFragmentById(
                    **R.id.map)).getMap();**

            // check if map is created successfully or not
            if (googleMap == null) {
                Toast.makeText(getApplicationContext(),
                        "Sorry! unable to create maps", Toast.LENGTH_SHORT)
                        .show();
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        initilizeMap();
    }

I bolded the places where I got the errors. Any help would be greatly appreciated!

Things I've tried: I've tried importing the R but it keeps trying to import the wrong R value.
I've tried cleaning the project.
edit: bolding does not work with code so never mind. it's where the ** ** is.

Hank G
  • 381
  • 3
  • 16
user2849976
  • 158
  • 1
  • 2
  • 10
  • check your resource files if you have any errors – Raghunandan May 08 '14 at 16:53
  • check your res folder for errors... – Lal May 08 '14 at 16:54
  • You are missing `` in your manifest.. But R.java is not being generated..Thats because you have some errors in your xml files – Lal May 08 '14 at 16:58
  • The tutorial you are referring is a bit old..MapFragment is deprecated now..Use SupportMapFragment..check this [link](http://stackoverflow.com/questions/20468169/simple-map-app-on-androidgoogle-api-v2-doesnt-work-error) for that.. – Lal May 08 '14 at 17:02
  • If you are using Eclipse, open your problem tab, fix all problems shown in xmls ( other than R related) and clean-build your application – Jimmy May 08 '14 at 17:03
  • I'm using android studio which is based on Eclipse. Is there a way to do that through this? – user2849976 May 08 '14 at 17:12
  • I never managed to solve the issue, but I do have less errors now. R is still not importing so there must be something else? – user2849976 May 08 '14 at 17:53

0 Answers0