エラー:注釈は-source 1.3でサポートされていない(5以上-source使用注釈を有効にします)

Pedram Davoodi:

私はアンドロイドに新たなんだと私はアンドロイドのスタジオで私の最初のテストプロジェクトをビルドしますが、このエラーを取得します

Javaコンパイラ

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

どのように私はそれを修正する必要がありますか?

これはエラーです

そして、これは私のGradleです

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

Vivekanandan:

私も同じ問題があったが、問題は私のことだったsourceCompatibilitytargetCompatibilityでは、compileOptionsを指した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'
}

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=312352&siteId=1