java - Android:错误:-source 1.3 中不支持注释

标签 java android kotlin

我试图添加一些模块,当我重建项目时我得到了这个错误:

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

我已经删除了模块,但错误仍然存​​在。 尝试清理和重建,没有帮助。

我知道它与 java maven 有关,但我不明白如何解决它。 也许这里有人可以提供帮助?

这是我的 Gradle :

buildscript {
ext.kotlin_version = '1.3.31'
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.4.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.2.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
 }

allprojects {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.java.net/content/groups/public/"
    }

    maven { url 'https://jitpack.io' }

    maven { url "https://maven.google.com" }


  }
}

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






apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'


android {
   compileSdkVersion 28
   defaultConfig {
      applicationId "com.eldareini.kotlin.meet4match"
      minSdkVersion 21
      targetSdkVersion 28
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner 
  "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

packagingOptions {
    pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
compileOptions {
    sourceCompatibility = kotlin_version
    targetCompatibility = kotlin_version
}
   buildToolsVersion = '28.0.3'
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.sun.mail:android-mail:1.6.0'
implementation 'com.sun.mail:android-activation:1.6.0'
implementation 'com.github.mac229.FragmentUtils:fragmentutils-kt:1.0.1'
implementation 'com.github.mac229.FragmentUtils:fragmentutils:1.0.1'
implementation 'com.sun.mail:android-mail:1.6.0'
implementation 'com.sun.mail:android-activation:1.6.0'
implementation 'org.webrtc:google-webrtc:1.0.+'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

最佳答案

您正在使用库的 Kotlin 版本来指定构建的源/目标兼容性。

问题出在这里:

compileOptions {
    sourceCompatibility = kotlin_version
    targetCompatibility = kotlin_version
}

kotlin_version1.3

尝试以下操作:

compileOptions {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

关于java - Android:错误:-source 1.3 中不支持注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56621169/

相关文章:

java - 我如何从匿名类访问我的主类?

android - 按钮应该粘在底部,带有 adjustResize

java - Struts 2 验证不适用于动态表单字段

java - Java 中 int 和 Integer 行为更改所需的常量表达式

Java:明智的类

android - 将页脚添加到 ListView 引发 "cannot be cast to android.widget.HeaderViewListAdapter"

java - 获取不同运营商的Cell ID

java - Android中如何连接蓝牙设备?

android - 杀死导航 Controller 中的 fragment

spring-boot - 使用 Kotlin 观察参数类型不匹配的 Spring Amqp Remoting