dictionary - Kotlin with Map in Android -
override fun oncreateview(inflater: layoutinflater?, container: viewgroup?, savedinstancestate: bundle?): view { var view: view = inflater?.inflate(r.layout.map_fragment, null)!! var mapfragment : supportmapfragment?=null mapfragment= fragmentmanager.findfragmentbyid(r.id.map) supportmapfragment mapfragment.getmapasync(this) return view }
logcat :
fatal exception: main kotlin.typecastexception: null cannot cast non-null type com.google.android.gms.maps.supportmapfragment @ example.com.kotlinexamplebydimple.mapfragment.oncreateview(mapfragment.kt:36)
on line error showing :
mapfragment= fragmentmanager.findfragmentbyid(r.id.map) supportmapfragment
you declared mapfragment
nullable have deal it:
var mapfragment : supportmapfragment?=null mapfragment = fragmentmanager.findfragmentbyid(r.id.map) supportmapfragment? mapfragment?.getmapasync(this)
Comments
Post a Comment