Skip to content Skip to sidebar Skip to footer

R.java Doesn't Have Map For R.id.map

So I'm following this guide TO THE LETTER (or at least trying to). And aside from having to import some things not specified in the guide, everything is fine EXCEPT there is a red

Solution 1:

Seems to me that Step 7 is the one where your missing resource comes from:

Update res/layout/activity_main.xml and replace the entire contents with

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/map"  android:layout_width="match_parent" 
 android:layout_height="match_parent"class="com.google.android.gms.maps.SupportMapFragment"/>

In Eclipse you need to:

  1. Change the file
  2. Save it
  3. Clean your project (to regenerate the resoureces, among them R.java)

Solution 2:

If u have android:id="@+id/activity_main" instead of android:id="@+id/map" in the activity_main.xml. This error is probable.

I got the similar error.I replaced

<fragment xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/activity_map"android:name="com.google.android.gms.maps.SupportMapFragment"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MapsActivity" />

to

<fragment xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/map"android:name="com.google.android.gms.maps.SupportMapFragment"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MapsActivity" />

Post a Comment for "R.java Doesn't Have Map For R.id.map"