为什么我不能只写 class.kotlin
而不是写 class.java。
因为 AndroidMeActivity
是一个 kotlin 类,所以当我写这个时出现错误 ("Unsoloved refrence: java")
,
我该如何解决。
val intent = Intent(this, AndroidMeActivity::class.java)
最佳答案
"Unsoloved refrence: java"
Reflection is a set of language and library features that allows for introspecting the structure of your own program at runtime.
确保,您添加了 org.jetbrains.kotlin:kotlin-gradle-plugin
buildscript {
ext.kotlin_version = '1.2.30'
ext.gradle_version = '3.0.1'
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
并检查您在下面添加的模块级别 build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
关于java - Kotlin 的 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49356990/