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

后端 未结 10 1222
予麋鹿
予麋鹿 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:35

    I Put in the beginning of Gradle (Module app)

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-android-extensions'
    

    and

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    

    or

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

    in the dependencies section

    In the build.gradle (Project)

    buildscript {
        ext.kotlin_version = '1.2.0'
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.0.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    

提交回复
热议问题