运行出错的地方:
lateinit var sp : SharedPreferences
sp = getPreferences(Context.MODE_PRIVATE)
override fun onPause() {
super.onPause()
sp.edit { //sp.eidt是出错的地方,因为此处sp.eidt参数的用法是lambda表达式
putInt("count_reserved",viewModel.counter)
}
}
编译报错的详细内容:
Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6.Please specify proper ‘-jvm-target’ option
解决方案:
在app模块的build.gradle文件中添加如下配置:
kotlinOptions{
jvmTarget =1.8
}