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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -