构建蚂蚁错误编译失败;在行 fork="${need.javac.fork}"; [英] build ant error Compile failed; at line fork="${need.javac.fork}"

查看:25
本文介绍了构建蚂蚁错误编译失败;在行 fork="${need.javac.fork}";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试构建我的项目时出现错误

When i try to build my project i got error

行 custom_rules.xml:63 是:第 78 行是: fork="${need.javac.fork}">

line custom_rules.xml:63 is: line 78 is : fork="${need.javac.fork}">

build的参数是-Dsdk.dir=C:Usersousdk-Ddeploy.env=preprod_artiste1- 详细构建后我想用 res-xxxxxx es-artiste1 es 中的另一个 res 替换文件夹 res

Parameters of build are -Dsdk.dir=C:Usersousdk -Ddeploy.env=preprod_artiste1 -verbose after build i want replace folder res by another res in res-xxxxxx es-artiste1 es

 BUILD FAILED

    C:Usersou
ative-androidcustom_rules.xml:63: The following error occurred while executing          
this line:
  C:Usersou
ative-androidcustom_rules.xml:78: Compile failed; see the compiler error output    
 for details.
at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:551)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:401)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at   

 org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)


at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
 Caused by: C:Usersou
ative-androidcustom_rules.xml:78: Compile failed; see the compiler    error output for details.
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1174)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:930)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
... 15 more



      build.xml is: 

     <?xml version="1.0" encoding="UTF-8"?>
   <project
name="xxxxxx"
default="help" >
<record name="buildddddddddddddddddddddd.log" loglevel="verbose" action="start" />
<!--
     The local.properties file is created and updated by the 'android' tool.
     It contains the path to the SDK. It should *NOT* be checked into
     Version Control Systems.
-->

<condition
    else="default.properties"
    property="deploy.env.path"
    value="config_${deploy.env}.properties" >

    <isset property="deploy.env" />
</condition>

<property file="${deploy.env.path}" />

<!--
     The ant.properties file can be created by you. It is only edited by the
     'android' tool to add properties to it.
     This is the place to change some Ant specific build properties.
     Here are some properties you may want to change/update:

     source.dir
         The name of the source directory. Default is 'src'.
     out.dir
         The name of the output directory. Default is 'bin'.

     For other overridable properties, look at the beginning of the rules
     files in the SDK, at tools/ant/build.xml

     Properties related to the SDK location or the project target should
     be updated using the 'android' tool with the 'update' action.

     This file is an integral part of the build system for your
     application and should be checked into Version Control Systems.

-->

<property file="ant.properties" />

<!--
     if sdk.dir was not set from one of the property file, then
     get it from the ANDROID_HOME env var.
     This must be done before we load project.properties since
     the proguard config can use sdk.dir
-->

<property environment="env" />

<condition
    property="sdk.dir"
    value="${env.ANDROID_HOME}" >

    <isset property="env.ANDROID_HOME" />
</condition>

<!--
     The project.properties file is created and updated by the 'android'
     tool, as well as ADT.

     This contains project specific properties such as project target, and library
     dependencies. Lower level build properties are stored in ant.properties
     (or in .classpath for Eclipse projects).

     This file is an integral part of the build system for your
     application and should be checked into Version Control Systems.
-->

<loadproperties srcFile="project.properties" />

<!-- quick check on sdk.dir -->

<fail
    message="sdk.dir is missing. Make sure to generate local.properties using &apos;android update project&apos; or to inject it through the ANDROID_HOME environment variable."
    unless="sdk.dir" />

<!--
    Import per project custom build rules if present at the root of the project.
    This is the place to put custom intermediary targets such as:
        -pre-build
        -pre-compile
        -post-compile (This is typically used for code obfuscation.
                       Compiled code location: ${out.classes.absolute.dir}
                       If this is not done in place, override ${out.dex.input.absolute.dir})
        -post-package
        -post-build
        -pre-clean

-->

<import
    file="custom_rules.xml"
    optional="true" />

<!--
     Import the actual build file.

     To customize existing targets, there are two options:
     - Customize only one target:
         - copy/paste the target into this file, *before* the
           <import> task.
         - customize it to your needs.
     - Customize the whole content of build.xml
         - copy/paste the content of the rules files (minus the top node)
           into this file, replacing the <import> task.
         - customize to your needs.

     ***********************
     ****** IMPORTANT ******
     ***********************
     In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
     in order to avoid having your file be overridden by tools such as "android update project"

-->
<!-- version-tag: 1 -->

<import file="${sdk.dir}/tools/ant/build.xml" />

 </project>

和 custom.xml 是:

and custom.xml is:

   <?xml version="1.0" encoding="UTF-8"?>
  <project name="custom" default="pre-compile">
<!--
    Import per project custom build rules if present at the root of the project.
    This is the place to put custom intermediary targets such as:
        -pre-build
        -pre-compile
        -post-compile (This is typically used for code obfuscation.
                       Compiled code location: ${out.classes.absolute.dir}
                       If this is not done in place, override ${out.dex.input.absolute.dir})
        -post-package
        -post-build
        -pre-clean
    -->

  <property name="generated.dir" value=".apt_generated" />
  <property name="generated.absolute.dir" location="${generated.dir}" />
  <property name="java.compilerargs" value="-s &apos;${generated.absolute.dir}&apos;" />
  <property name="generated.dir" value=".apt_generated" /> 


<property name="xxxxxx.ressource.dir.path" location="${xxxxxx.ressource.dir}" />
<condition property="resource.absolute.dir" value="${xxxxxx.ressource.dir.path}">
   <isset property="xxxxxx.ressource.dir" />
</condition> 

<condition property="asset.dir" value="${xxxxxx.assets.dir}">
   <isset property="xxxxxx.assets.dir" />
</condition>


  <target name="-pre-compile">


    <mkdir dir="${generated.absolute.dir}" />



  </target>


 <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}">
            <src path="${source.absolute.dir}" />
            <src path="${gen.absolute.dir}" />
            <compilerarg line="${java.compilerargs}" />
        </javac>

        <!-- if the project is instrumented, intrument the classes -->
        <if condition="${build.is.instrumented}">
            <then>
                <echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...   
       </echo>

                <!-- build the filter to remove R, Manifest, BuildConfig -->
                <getemmafilter
                        appPackage="${project.app.package}"
                        libraryPackagesRefId="project.library.packages"
                        filterOut="emma.default.filter"/>

                <!-- define where the .em file is going. This may have been
                     setup already if this is a library -->
                <property name="emma.coverage.absolute.file" 
                location="${out.absolute.dir}/coverage.em" />

                <!-- It only instruments class files, not any external libs -->
                <emma enabled="true">
                    <instr verbosity="${verbosity}"
                           mode="overwrite"
                           instrpath="${out.absolute.dir}/classes"
                           outdir="${out.absolute.dir}/classes"
                           metadatafile="${emma.coverage.absolute.file}">
                        <filter excludes="${emma.default.filter}" />
                        <filter value="${emma.filter}" />
                    </instr>
                </emma>
            </then>
        </if>

        <!-- if the project is a library then we generate a jar file -->
        <if condition="${project.is.library}">
            <then>
                <echo level="info">Creating library output jar file...</echo>
                <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" 
          />
                <if>
                    <condition>
                        <length string="${android.package.excludes}" trim="true" when="greater" 
       length="0" />
                    </condition>
                    <then>
                        <echo level="info">Custom jar packaging exclusion: 
       ${android.package.excludes}</echo>
                    </then>
                </if>

                <propertybyreplace name="project.app.package.path" input="${project.app.package}" 
          replace="." with="/" />

                <jar destfile="${out.library.jar.file}">
                    <fileset dir="${out.classes.absolute.dir}"
                            includes="**/*.class"
                            excludes="${project.app.package.path}/R.class 
         ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/>
                    <fileset dir="${source.absolute.dir}" excludes="**/*.java 
       ${android.package.excludes}" />
                </jar>
            </then>
        </if>

    </do-only-if-manifest-hasCode>
   </target>


  <target name="-package-resources" depends="-crunch">

 <!-- only package resources if *not* a library project -->
    <do-only-if-not-library elseText="Library project: do not package resources..." >
        <aapt executable="${aapt}"

                command="package"
                versioncode="${version.code}"
                versionname="${version.name}"
                debug="${build.is.packaging.debug}"
                manifest="${out.manifest.abs.file}"
                assets="${asset.absolute.dir}"
                androidjar="${project.target.android.jar}"
                apkfolder="${out.absolute.dir}"
                nocrunch="${build.packaging.nocrunch}"
                resourcefilename="${resource.package.file.name}"
                resourcefilter="${aapt.resource.filter}"
                libraryResFolderPathRefid="project.library.res.folder.path"
                libraryPackagesRefid="project.library.packages"
                libraryRFileRefid="project.library.bin.r.file.path"
                previousBuildType="${build.last.target}"
                buildType="${build.target}"
                ignoreAssets="${aapt.ignore.assets}" 
                manifestpackage="${xxxxxx.packagename}"
                >
             <res path="${out.res.absolute.dir}" />
            <res path="${resource.absolute.dir}" />

            <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
            <!-- <nocompress extension="xml" /> forces no compression on specific file extensions 
          in assets and res/raw -->
        </aapt>

    </do-only-if-not-library>
  </target>


 </project>

我遇到了这个错误,因为两天需要帮助,谢谢

i gow this error since two days need help please, thanks

推荐答案

我是这样解决问题的

在我的 custom_rules.xml 中添加

in my custom_rules.xml i add

 <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}">
            <src path="${source.absolute.dir}" />
            <src path="${gen.absolute.dir}" />
            <compilerarg line="${java.compilerargs}" />
        </javac>

        <!-- if the project is instrumented, intrument the classes -->
        <if condition="${build.is.instrumented}">
            <then>
                <echo level="info">Instrumenting classes from ${out.absolute.dir}/classes...</echo>

                <!-- build the filter to remove R, Manifest, BuildConfig -->
                <getemmafilter
                        appPackage="${project.app.package}"
                        libraryPackagesRefId="project.library.packages"
                        filterOut="emma.default.filter"/>

                <!-- define where the .em file is going. This may have been
                     setup already if this is a library -->
                <property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />

                <!-- It only instruments class files, not any external libs -->
                <emma enabled="true">
                    <instr verbosity="${verbosity}"
                           mode="overwrite"
                           instrpath="${out.absolute.dir}/classes"
                           outdir="${out.absolute.dir}/classes"
                           metadatafile="${emma.coverage.absolute.file}">
                        <filter excludes="${emma.default.filter}" />
                        <filter value="${emma.filter}" />
                    </instr>
                </emma>
            </then>
        </if>

        <!-- if the project is a library then we generate a jar file -->
        <if condition="${project.is.library}">
            <then>
                <echo level="info">Creating library output jar file...</echo>
                <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
                <if>
                    <condition>
                        <length string="${android.package.excludes}" trim="true" when="greater" length="0" />
                    </condition>
                    <then>
                        <echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo>
                    </then>
                </if>

                <propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" />

                <jar destfile="${out.library.jar.file}">
                    <fileset dir="${out.classes.absolute.dir}"
                            includes="**/*.class"
                            excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/>
                    <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
                </jar>
            </then>
        </if>

    </do-only-if-manifest-hasCode>
</target>


  <target name="-package-resources" depends="-crunch">

 <!-- only package resources if *not* a library project -->
    <do-only-if-not-library elseText="Library project: do not package resources..." >
        <aapt executable="${aapt}"

                command="package"
                versioncode="${version.code}"
                versionname="${version.name}"
                debug="${build.is.packaging.debug}"
                manifest="${out.manifest.abs.file}"
                assets="${asset.absolute.dir}"
                androidjar="${project.target.android.jar}"
                apkfolder="${out.absolute.dir}"
                nocrunch="${build.packaging.nocrunch}"
                resourcefilename="${resource.package.file.name}"
                resourcefilter="${aapt.resource.filter}"
                libraryResFolderPathRefid="project.library.res.folder.path"
                libraryPackagesRefid="project.library.packages"
                libraryRFileRefid="project.library.bin.r.file.path"
                previousBuildType="${build.last.target}"
                buildType="${build.target}"
                ignoreAssets="${aapt.ignore.assets}" 
                manifestpackage="${fantouch.packagename}"
                >
             <res path="${out.res.absolute.dir}" />
            <res path="${resource.absolute.dir}" />

            <!-- <nocompress /> forces no compression on any files in assets or res/raw -->
            <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
        </aapt>

    </do-only-if-not-library>
</target>

这篇关于构建蚂蚁错误编译失败;在行 fork="${need.javac.fork}";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆