google maps are returning null pointer exception

后端 未结 3 1849
孤城傲影
孤城傲影 2021-01-29 02:09

when I am trying to show the maps on my fragment it is returning null pointer exception. I have added everything to the manifest each and every permission. I am attaching the f

3条回答
  •  故里飘歌
    2021-01-29 02:56

    Replace this code

    SupportMapFragment mapFrag = (SupportMapFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.map);
    googleMap = mapFrag.getMap();
    

    with

    googleMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map)).getMap();
    

    Check it!

提交回复
热议问题