Trouble implementing getMapAsync in Google Maps

前端 未结 1 349
北海茫月
北海茫月 2020-12-19 16:31

I am trying to put a map with a marker in an activity in an Android app. It compiles and builds fine, but when I try to run the activity the app crashes and I get the messag

相关标签:
1条回答
  • 2020-12-19 17:16

    Your xml is using a MapFragment, not a SupportMapFragment.

    Change your xml to use a SupportMapFragment and it should work:

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

    Also, make sure that you're inflating the correct layout in the call to setContentView().

    0 讨论(0)
提交回复
热议问题