prolink007
prolink007

Reputation: 34544

Target "${build.target}" does not exist in the project "AppNameA"

Error is at the bottom

I am getting this error during the -build-setup task when trying to run a build.xml file (generated by the android sdk) for a project that has a couple dependencies and the task i am trying to run is -compile. I am using eclipse to run this ant file using the auto build function. I assigned this build.xml file as a builder for the project and set it as the only bulider. Then set the targets to the following:

<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="-compile,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="-compile,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="clean,nodeps,debug,"/>

Both the dependencies are also using the generated build.xml files. All of my build.xml files are over riding the -compile task. Posted at the bottom is the -compile task that is in the build.xml files.

The dependency projects are android libraries and i have their ant builder configured in eclipse as the following:

<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="nodeps,debug,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="nodeps,debug,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="debug,"/>

Why do i keep getting this error and how do i fix this?



My current work around

If i change the targets of the AppNameA to the following, it works fine. However, i do not want to have to do this... debug takes too long when all you really want is to compile at those points.

<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AFTER_CLEAN_TARGETS" value="debug,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_AUTO_TARGETS" value="debug,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/>
<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_MANUAL_TARGETS" value="clean,nodeps,debug,"/>

Here is the exact error:

BUILD FAILED
C:\Users\myusername\android-sdks\tools\ant\build.xml:485: The following error occurred while executing this line:
Target "${build.target}" does not exist in the project "AppNameA". 

The -compile task that is in the build.xml files.

(Basically the same as the original, there is one minor change...)

<!-- Compiles this project's .java files into .class files. -->
<target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
    <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
        <!-- If android rules are used for a test project, its classpath should include
             tested project's location -->
        <condition property="extensible.classpath"
                value="${tested.project.absolute.dir}/bin/classes"
                else=".">
            <isset property="tested.project.absolute.dir" />
        </condition>
        <condition property="extensible.libs.classpath"
                value="${tested.project.absolute.dir}/${jar.libs.dir}"
                else="${jar.libs.dir}">
            <isset property="tested.project.absolute.dir" />
        </condition>
        <javac encoding="${java.encoding}"
                source="${java.source}" target="${java.target}"
                debug="true" extdirs="" includeantruntime="false"
                destdir="${out.classes.absolute.dir}"
                bootclasspathref="android.target.classpath"
                verbose="${verbose}"
                classpath="${extensible.classpath}"
                classpathref="jar.libs.ref"
                excludes="${filesToExcludeFromCompile}"
                failonerror="true"
            >
            <src path="${source.absolute.dir}" />
            <src path="${gen.absolute.dir}" />
            <classpath>
                <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
            </classpath>
            <compilerarg line="${java.compilerargs}" />
        </javac>
        <!-- if the project is a library then we generate a jar file -->
        <if condition="${project.is.library}">
            <then>
                <echo>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>Custom jar packaging exclusion: ${android.package.excludes}</echo>
                    </then>
                </if>
                <jar destfile="${out.library.jar.file}">
                    <fileset dir="${out.classes.absolute.dir}" excludes="**/R.class **/R$*.class"/>
                    <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
                </jar>
            </then>
        </if>

        <!-- if the project is instrumented, intrument the classes -->
        <if condition="${build.is.instrumented}">
            <then>
                <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
                <!-- 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">
                    </instr>
                    <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
                         user defined file -->
                </emma>
            </then>
        </if>
    </do-only-if-manifest-hasCode>
</target>

Upvotes: 3

Views: 10809

Answers (2)

prolink007
prolink007

Reputation: 34544

I figured out the problem.

${build.target} is actually set in the -set-debug-mode and -set-release-mode tasks. So, when calling the -compile task directly it is not calling either of those tasks as dependencies.

Therefor, ${build.target} is never actually set.

A workaround for this is to override one of the tasks and have it set the ${build.target} when it is not set. Have it set to some default you approve.

Upvotes: 2

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 77971

A property called java.target is unset in your build.xml file.

I reckon the message is being thrown by the following ANT task, which has an attribute called "target":

<javac encoding="${java.encoding}"
        source="${java.source}" target="${java.target}"
        debug="true" extdirs="" includeantruntime="false"
        destdir="${out.classes.absolute.dir}"
        bootclasspathref="android.target.classpath"
        verbose="${verbose}"
        classpath="${extensible.classpath}"
        classpathref="jar.libs.ref"
        excludes="${filesToExcludeFromCompile}"
        failonerror="true"
    >

Upvotes: 0

Related Questions