Google Map returning nullpointerexception Google Maps Android V2

喜夏-厌秋 提交于 2019-11-28 01:38:04
Javed Ali
googleMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)).getMap();

This worked for me. getSupportFragmentManager() seemed to be causing all the crashes.

MainActivity.xml :

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

MainActivity.java :

Private GoogleMap GoogleMap;
googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

Here's the permission:

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

And here's the metadata section:

...

<meta-data android:name="com.google.android.maps.v2.API_KEY"
           android:value="HERE GOES YOUR API KEY" />

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!