Gurvinder Singh Gurvinder Singh - 6 months ago 62
Android Question

getMap() is null in SupportMapFragment in gogole map in andorid fragment

I am using google map in a fragment and getting null when calling getMap(), this is my code:

In my MapViewFragment

private GoogleMap mGoogleMap;

I am getting null at this line, in onCreate() method...

mGoogleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(;

In fragment_map_view file


Please suggest.


I got the reason for it, I think I should post for future readers......

Actually as I GoogleMap was called in a fragment so, in the line..

mGoogleMap = ((SupportMapFragment) getFragmentManager().findFragmentById(;

instead of

getFragmentManager(), getSupportFragmentManager() should be used in fragments.

Corrected one-

mGoogleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(;