当我尝试启动构建ant时,我会出现以下错误:
[javac] Compiling 12 source files to C:UsersbrahimAndroid*********_Presentationbinclasses
[javac] C:UsersbrahimAndroid*********_Presentationsrccom*******activityAbstractActivity.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:UsersbrahimAndroid*********_Presentationcustom_rules.xml:47: The following error occurred while executing this line:
C:UsersbrahimAndroid********_Presentationcustom_rules.xml:62: Compile failed; see the compiler error output for details.
我的客户规则第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
问题已经解决了,为什么eclipseant默认采用1.5版本?
看起来${java.source}
低于1.7
,或者您使用低于1.7的JDK版本来编译应用程序。将其更改为JDK1.7或更高版本以解决您的问题。