[kotlin.KotlinNullPointerException启动我的应用程序时

问题描述 投票:0回答:1

输出

kotlin.KotlinNullPointerException在org.opencv.samples.facedetect.FdActivity.getNumLabels(FdActivity.kt:448)在org.opencv.samples.facedetect.FdActivity.onCameraFrame(FdActivity.kt:219)

代码

protected val numLabels: Int  
    protected get() = labelList!!.size //this is where the nullpointer is detected
protected val numLabelsG: Int
    protected get() = labelListG!!.size


    try {
        labelListG = loadLabelListG()
    } catch (e: Exception) {
    }
    try {
        labelList = loadLabelList() //this is where the nullpointer is detected
    } catch (e: Exception) {
    }

问题] >>

我将我的java文件转换为kotlin文件,并设法解决了一些错误,但是在启动我的应用程序时遇到了这个问题。为什么我总是收到kotlin.KotlinNullPointerException?

https://kotlinlang.org/docs/reference/null-safety.html

kotlin kotlin-android-extensions
1个回答
0
投票
检查值是否为空
© www.soinside.com 2019 - 2024. All rights reserved.