【问题标题】:build ant project android error构建ant项目android错误
【发布时间】: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吗?

标签: java android ant build


【解决方案1】:

看起来 ${java.source} 低于 1.7 或者您使用低于 1.7 的 JDK 版本来编译您的应用程序。将其更改为 JDK 1.7 或更高版本以解决您的问题。

【讨论】:

  • 我已经这样做了,在ant build配置表jre中我选择了jdk1.7,在属性java编译器中也是如此
猜你喜欢
  • 1970-01-01
  • 2011-03-11
  • 1970-01-01
  • 2011-11-02
  • 2012-05-31
  • 2011-11-06
  • 1970-01-01
  • 2013-06-13
  • 1970-01-01
相关资源
最近更新 更多