【问题标题】:The compiler compliance specified is 1.6 but a JRE 1.8 is used指定的编译器合规性为 1.6,但使用了 JRE 1.8
【发布时间】:2019-10-15 17:47:18
【问题描述】:

我的eclipse报了"The compiler compliance specified is 1.6 but a JRE 1.8 is used".的警告

我已经使用 Java1.8, 构建了我的 HelloWorld Android 应用程序,但是,我收到了警告,我无法构建我的项目。我试图将编译器合规性设置为 java1.8。但是我遇到了另一个错误

“Android 要求编译器合规级别为 5.0 或 6.0。发现 '1.8'”

.我不知道如何解决这个问题?

【问题讨论】:

  • 我在一个 Maven 项目中遇到了类似的问题(与 Android 无关),下面 Patel Romil 的第二个建议成功了!

标签: java android eclipse


【解决方案1】:

可能的解决方案:

  1. 右键单击您的项目并选择"Android Tools -> Fix Project Properties"。 (如果这不起作用,请尝试以下选项)
  2. 右键单击您的项目并选择"Properties -> Java Compiler",勾选“启用项目特定设置”并选择 “编译器合规性设置”选择框中的 1.5 或 1.6。
  3. Window -> Preferences -> Java -> Compiler下,设置编译器 合规级别为 1.5 或 1.6。

【讨论】:

  • 我已经尝试过了,但没有成功。我仍然收到错误消息:在项目“HelloWorld”上运行构建器“Android Package Builder”时出错。 sun/misc/BASE64Encoder
  • @Jessie as from the information The compiler compliance specified is 1.6, so please recheck all properties are with 1.6 if errors are still there, update with the errors
  • 我重新检查了属性,我认为都是1.6。而且我仍然收到警告说“指定的编译器合规性是 1.6,但使用了 JRE 1.8”,并且我无法构建我的项目,并出现错误“在项目 'HelloWorld'.sun/misc/BASE64Encoder 上运行构建器'Android Package Builder'时出错”
  • @Jessie 在 Eclipse 中,转到 Window > Preferences > Installed JREs > Execution Environment 并选择 JavaSE 1.6(它应该在那里)并选择 jdk1.6 并重新启动 eclipse
  • @Jessie 此外,eclipse.ini 还引用了它使用的 Java VM。确保它指向的 VM 是 Java 1.6(请参阅有关如何找到它以及如何设置 VM 首选项的链接)。 wiki.eclipse.org/Eclipse.ini
【解决方案2】:

转到Windows>首选项>java>编译器。 勾选“使用默认合规设置”复选框,然后应用并关闭。 右键单击项目并转到构建路径>配置构建路径 在库选项卡下删除 JRE 系统库并单击添加库 选择单选框执行环境并选择环境 应用和关闭

【讨论】:

    【解决方案3】:

    需要在项目的文件夹名称下进行以下更改:-

    .设置

    eclipse.preferences.version=1
    org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
    org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
    org.eclipse.jdt.core.compiler.compliance=1.8
    org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
    org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
    org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
    org.eclipse.jdt.core.compiler.processAnnotations=disabled
    org.eclipse.jdt.core.compiler.release=disabled
    org.eclipse.jdt.core.compiler.source=1.8
    

    IDE configuration

    【讨论】:

      【解决方案4】:

      我正在开发 VSCode,我刚刚做了下一件事 我将 pom.xml 中的版本更改为我在计算机上安装的版本

      <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
              <maven.compiler.source>1.11</maven.compiler.source>
              <maven.compiler.target>1.11</maven.compiler.target>
          <java.version>1.11</java.version>
          </properties>
      

      之前我有 1.8,现在有 1.11

      【讨论】:

      • 这并没有解决精通eclipse的原始问题,如果您提出问题并做出自己的回答,这可能是一个好主意,它会给您虚假的互联网积分
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-29
      相关资源
      最近更新 更多