Cam Connor
Cam Connor

Reputation: 1231

Google maps android API v2 crashes instantly when opened

I am trying to use the google maps API v2 for android and I followed these instructions exactly

https://developers.google.com/maps/documentation/android/start

and everything works fine until I put this code into the layout file

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

once that code is put in the app crashes when opened, this picture also appears on the graphical layoutenter image description here

Thanks in advance!

Upvotes: 0

Views: 283

Answers (1)

Shadow
Shadow

Reputation: 6899

Use support Mapfragment

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

GoogleMap gm;

  gm = ((SupportMapFragment(getSupportFragmentManager().findFragmentById(R.id.map))).getMap();    
  gm.setMapType(GoogleMap.MAP_TYPE_NORMAL);

Upvotes: 1

Related Questions