您好,我要运行App时出错: 错误:
C:\ Users ... \ AndroidStudioProjects \ projects \ HelloWorld \ app \ src \ main \ java \ training \ androidkotlin \ helloworld \ MainActivity.kt:(8,5):意外覆盖:以下声明具有相同的含义JVM签名(onCreate(Landroid / os / Bundle;)V): fun onCreate(savedInstanceState:Bundle):在training.androidkotlin.helloworld.MainActivity中定义的单位 fun onCreate(p0:Bundle?):在training.androidkotlin.helloworld.MainActivity中定义的单位
代码:
package training.androidkotlin.helloworld
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
@Override
protected fun onCreate(savedInstanceState: Bundle) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
请问如何解决? 谢谢
答案 0 :(得分:1)
在Kotlin中,df <- structure(list(ITEM = c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L,
4L), ID = c("A", "B", "C", "D", "E", "F", "G", "A", "B", "C",
"H"), Score = c(7L, 8L, 7L, 3L, 5L, 4L, 6L, 9L, 10L, 5L, 8L),
Date = c("1/1/2018", "1/3/2018", "1/6/2018", "1/7/2017",
"1/10/2017", "1/1/2003", "1/3/2004", "1/5/2008", "1/7/2010",
"1/8/2010", "1/3/2011")), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11"))
是一个关键字,因此将@Override
更改为@Override fun xx
可以解决此问题。
答案 1 :(得分:-1)
非常感谢您提出的所有建议,我解决了这个问题。 1.我尝试重新安装Android Studion,以防万一在安装过程中出现故障,并且我更改了代码:
package training.androidkotlin.helloworld
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
@Override
protected override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
再一次感谢您抽出宝贵时间给我答案的每一个人。 干杯!