i have error in android studio with kotlin

后端 未结 1 1848
醉话见心
醉话见心 2021-01-29 15:00

why this error?

09-12 16:36:31.502 1886-1886/com.getloction.nourmedhat.smartgate.getlocation E/AndroidRuntime: FATAL EXCEPTION: main Process: com.getloction

相关标签:
1条回答
  • 2021-01-29 15:44

    As commented by AlexTa you're getting a TypeCastException because you cast null to a non-null type.

    In Kotlin types are "@NotNull" by default. So if you declare a variable like this:

    var yourVar: String
    

    you cannot assign null to it. If it should be capable of storing null (which it often shouldn't) you declare it like this:

    var yourVar: String? = null
    
    0 讨论(0)
提交回复
热议问题