错误:-source 1.3不支持注释(使用-source 5或更高版本启用注释)

时间:2019-10-11 09:24:28

标签: java android android-studio kotlin

我是android新手,我在android studio中构建了我的第一个测试项目,但遇到此错误

Java编译器

error: annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)

我应该如何解决?

This is the Error

这是我的礼物

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}


allprojects {
    repositories {
        google()
        jcenter()
        
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

1 个答案:

答案 0 :(得分:3)

我也遇到了同样的问题,问题是我的sourceCompatibility中的targetCompatibilitycompileOptions指向kotlin_version,将它们设置为项目中的正确Java版本级别build.gradle文件。

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "x.y.z"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    buildToolsVersion = '28.0.3'
}