android - 语言级别1.3 android studio不支持注释

标签 android android-studio kotlin build

我在Android Studio 3.5.3中使用Kotlin 1.3.11创建了新项目

问题是我构建项目时出现此错误

错误

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



或这个

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



发生错误时在源中显示此

annotation are not supported at language level 1.3



也是这个错误是由 Dagger 生成的文件

最佳答案

发生这种情况是因为您的Kotlin使用Java 1.3编译器。
要解决此问题,您可以将其添加到构建/升级

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
}



其他方式修复所有项目。
  • 打开IntelliJ首选项
  • 转到构建,执行,部署>编译器> Kotlin编译器BUT
    其他设置> Kotlin编译器(如果Android Studio)> 3.4
  • 将目标JVM版本更改为1.8
  • 单击应用
  • 关于android - 语言级别1.3 android studio不支持注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60473222/

    相关文章:

    Android Lint 消息 : Update to Fragment 1. 3.0 在分析/检查代码中使用 ActivityResult API 错误

    android - 如何让LiveData在另外两个LiveData之间切换

    android - IllegalStateException : Default FirebaseApp is not initialized in this process. 确保先调用 FirebaseApp.initializeApp(Context)

    android - 运行应用程序与应用更改 android studio 2.3

    Android Studio Dex 截止大小

    android - 如何从一个地方更改整个应用程序中的默认ClickSound

    android - EditText TextChangeListener 问题

    java - PayPal 支付 Activity 中的空异常

    android - 将多个 unity3d 项目导入到 android studio?

    android - 从android通知中删除辅助图标