当我尝试启动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 =&#34; 1.7&#34; 并且还硬编码$ {java.target} = 1.7
问题已经消失,为什么eclipse ant默认使用1.5版本?
答案 0 :(得分:0)
看起来${java.source}
低于1.7
,或者您使用低于1.7的JDK版本来编译您的应用。将其更改为JDK 1.7或更高版本以解决您的问题。