i have error in android studio with kotlin -
why error?
09-12 16:36:31.502 1886-1886/com.getloction.nourmedhat.smartgate.getlocation e/androidruntime: fatal exception: main process: com.getloction.nourmedhat.smartgate.getlocation, pid: 1886 kotlin.typecastexception: null cannot cast non-null type kotlin.string @ com.getloction.nourmedhat.smartgate.getlocation.all_station$oncreate$2.ondatachange(all_station.kt:56) @ com.google.android.gms.internal.to.zza(unknown source) @ com.google.android.gms.internal.vj.zzhx(unknown source) @ com.google.android.gms.internal.vp.run(unknown source) @ android.os.handler.handlecallback(handler.java:751) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:154) @ android.app.activitythread.main(activitythread.java:6682) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1520) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1410)
as commented alexta you're getting typecastexception because cast null non-null type.
in kotlin types "@notnull" default. if declare variable this:
var yourvar: string you cannot assign null it. if should capable of storing null (which shouldn't) declare this:
var yourvar: string? = null
Comments
Post a Comment