繁体   English   中英

生成ant项目android错误

[英]build ant project android error

当我尝试启动构建蚂蚁时,出现以下错误:

[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.7或者您使用的JDK版本低于1.7来编译您的应用程序。 将其更改为JDK 1.7或更高版本可以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM