In my app i showing google map version2 in a fragment. but i get Null pointer exception at
mMap = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id
if you developed your code with Kotlin, and want to add MapFragment to another Fragment you need to use SupportMapFragment
but if you do it, you will get null exception so you should use childFragmentManager
rather than supportFragmentManager
and the code should be in onCreateView
not in onCreate
just add below code:
private lateinit var mapFragment : SupportMapFragment
mapFragment = childFragmentManager.findFragmentById(R.id.mapview) as SupportMapFragment
mapFragment.getMapAsync { googleMap ->
this.googleMap = googleMap
setGoogleMapSettings()
}