今天在玩弄DataStore的時(shí)候,在MainActivity中新增了一個(gè)preferencesKey的時(shí)候突然發(fā)現(xiàn)報(bào)錯(cuò)了,鼠標(biāo)上去發(fā)現(xiàn)提示:
Cannot inline bytecode buit with JVM target 1.8 into bytecode that is being built with JVM target 1.6.Please specify proper '-jvm-target' option
解決辦法:在模塊下的build.gradle文件下添加代碼
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.fire.myreivces"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
//添加的主要代碼
kotlinOptions{
jvmTarget = "1.8"
}
sourceSets{
main{
proto{
srcDir 'src/main/proto'
}
}
}
}