此语言级别不支持菱形类型 [英] Diamond type are not supported at this language level

查看:44
本文介绍了此语言级别不支持菱形类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将项目导入 Android Studio 后,如果我想编译或运行该项目,它会引发错误:

After importing a project into Android studio, if I want to compile or run the project it throws an error:

错误:(61, 65) java: -source 1.6 不支持菱形运算符
(使用 -source 7 或更高版本来启用菱形运算符)

Error:(61, 65) java: diamond operator is not supported in -source 1.6
(use -source 7 or higher to enable diamond operator)

有谁知道它是什么以及如何解决它?

Does anyone know what it is and how to solve it ?

推荐答案

在 Android Studio(文件 -> 项目结构...,属性选项卡)中,设置以下值:

In Android Studio (File -> Project Structure..., Properties tab), set the following values:

Source Compatibility == 1.7
Target Compatibility == 1.7

在此之后,您的 build.gradle 将具有以下条目:

After this your build.gradle will have these entries:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

这篇关于此语言级别不支持菱形类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆