Null pointer exception at mapFragment.getMapAsync(this) while initializing google map

Finally I got the answer!

SupportMapFragment mapFragment = (SupportMapFragment) this.getChildFragmentManager()
                .findFragmentById(R.id.mapFragment);

instead of

SupportMapFragment mapFragment = (SupportMapFragment) this.getSupportFragmentManager()
                .findFragmentById(R.id.mapFragment);

getChildFragmentManager() did the trick.


In addition, If you are using SupportMapFragment mapFragment = (SupportMapFragment).....

Then be sure you have set this class attribute in XML

class="com.google.android.gms.maps.SupportMapFragment"

Not

class ="com.google.android.gms.maps.MapFragment"