使用IntelliJ IDE不能编译任何项目。设置截图如下:
使用JDK:
项目SDK及语言级别:
语言水平:
有人有什么想法吗?
使用IntelliJ IDE不能编译任何项目。设置截图如下:
使用JDK:
项目SDK及语言级别:
语言水平:
有人有什么想法吗?
当前回答
你需要进入设置,在Java编译器下设置如下:
同时检查项目设置
其他回答
在你的Gradle应用级别文件>> compileOptions中添加这两行
android {
compileOptions {
...
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
...
}
}
这看起来就像没有正确配置编译器插件时Maven生成的那种错误。下面是一个Java 8编译器配置的例子。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- ... -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<!-- ... -->
</project>
在compiler.xml文件下,你会发现:
<bytecodeTargetLevel>
<module name="your_project_name_main" target="1.8" />
<module name="your_project_name_test" target="1.8" />
</bytecodeTargetLevel>
你可以把目标值从旧的改为新的对我来说,我需要把它从1.5改为1.8
我只是重新导入maven按钮,然后错误消失了。
解决这个问题有两种方法:
设置(文件->设置->构建,执行,部署-> Java编译器): 在pom.xml中添加一个构建部分: