【发布时间】:2015-05-31 14:14:08
【问题描述】:
当我尝试启动 build ant 时出现此错误:
[javac] Compiling 12 source files to C:\Users\brahim\Android\****\*****_Presentation\bin\classes
[javac] C:\Users\brahim\Android\*****\****_Presentation\src\com\***\****\activity\AbstractActivity.java:29: error: diamond operator is not supported in -source 1.5
[javac] List<AbstractFragment> mHistoryNav = new ArrayList<>();
[javac] ^
[javac] (use -source 7 or higher to enable diamond operator)
[javac] 1 error
BUILD FAILED
C:\Users\brahim\Android\*****\****_Presentation\custom_rules.xml:47: The following error occurred while executing this line:
C:\Users\brahim\Android\****\****_Presentation\custom_rules.xml:62: Compile failed; see the compiler error output for details.
我的 custom_rules 的第 47 和 62 行是:
<target name="-compile" depends="-pre-build, -build-setup, -code-gen, -pre-compile">
<do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
<!-- merge the project's own classpath and the tested project's classpath -->
<path id="project.javac.classpath">
<path refid="project.all.jars.path" />
<path refid="tested.project.classpath" />
<path path="${java.compiler.classpath}" />
<fileset dir="compile-libs" includes="*.jar"/>
</path>
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="project.target.class.path"
verbose="${verbose}"
classpathref="project.javac.classpath"
fork="${need.javac.fork}">
有人知道我为什么会收到这个错误吗?
任何帮助将不胜感激,谢谢
编辑:
${java.source} = 1.5 当我对其进行硬编码时 yo =“1.7” 并且还硬编码 ${java.target} = 1.7
问题没有了,为什么eclipse ant默认取1.5版本?
【问题讨论】:
-
${java.source}的值是多少? -
= 1.5 ,我该如何更改?这很奇怪,因为我的 java 编译器设置为 sdk 1.7
-
尝试添加硬编码 source="1.7"
-
我收到此错误 [javac] 将 12 个源文件编译到 C:\Users\brahim\Android********_Presentation\bin\classes [javac] javac: source release 1.7 requires目标版本 1.7
-
您能否将其添加到您的问题中作为更新。你也可以回声
JAVA_HOME吗?