I want to add a map with an existing project, generated a key, added it to the Manifesto, did a rebuild project, then it is written in all tutorials that you need to create an xml of this type:

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

When I add this xml, Android Studio does not see android:name="com.google.android.gms.maps.MapFragment" and underlines this line in red. The question is, is there something else you need to import? Or this name does not affect anything? and can it be replaced / removed?

    3 answers 3

    Download Google play services in SDK Manager, another quick way to add maps to an existing project, File -> New -> Google ->Google Maps Activity .

      Import entire Google Play services:

       compile 'com.google.android.gms:play-services:9.8.0' 

      Or you can, as needed, for maps is enough:

       compile 'com.google.android.gms:play-services-location:9.8.0' compile 'com.google.android.gms:play-services-maps:9.8.0' 

        And you need to add a fragment like this.

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

        plus as written below add

         compile 'com.google.android.gms:play-services-maps:9.8.0'