DEV Community

nshmura
nshmura

Posted on

[Kotlin] ::class.java “Unresolved Reference: Java” error

I got “Unresolved Reference: Java” error in following code.

val clazz = String::class.java
Enter fullscreen mode Exit fullscreen mode

Loading kotlin-reflect library in build.gradle resolved this error.

dependencies {
    ...
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    // this line
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    ...
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)