kotlin项目报这种提示Please specify proper '-jvm-target' option

今天在玩弄DataStore的时候,在MainActivity中新增了一个preferencesKey的时候突然发现报错了,鼠标上去发现提示:

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'
            }
        }
    }
}

你可能感兴趣的:(kotlin项目报这种提示Please specify proper '-jvm-target' option)