Kotlin Foo::class.java “Unresolved Reference: Java” error

后端 未结 10 1230
予麋鹿
予麋鹿 2020-12-15 17:11

I am trying to convert my Java code of HomePage.class to Kotlin. I am following the instructions on Kotlin.org:

getClass()

10条回答
  •  借酒劲吻你
    2020-12-15 17:51

    For easy reference, here are the reflection dependencies when using Gradle:

    Reflection libraries from the docs for Gradle in your build.gradle

    dependencies {
        compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
        compile "org.jetbrains.kotlin:kotlin-reflect"
        testCompile "org.jetbrains.kotlin:kotlin-test"
        testCompile "org.jetbrains.kotlin:kotlin-test-junit"
    }
    

    Reflection libraries syntax for Kotlin Script Gradle DSL in your build.gradle.kts

    dependencies {
        compile(kotlin("stdlib"))
        compile(kotlin("reflect"))
        compile(kotlin("test"))
        compile(kotlin("test-junit"))
    }
    

提交回复
热议问题