Target "${build.target}" does not exist in the project "LibA" when running Android's build.xml from Gradle
Asked Answered
K

3

7

I have an Android project which depends on three android libraries. It's project.properties file looks like the following:

split.density=false
android.library.reference.2=..\\LibB
proguard.config=proguard.cfg
android.library.reference.1=..\\\\LibA\\\\
# Project target.
target=android-5
android.library.reference.3=../LibC


build.xml of this project is used just to depend on Gradle tasks:

<target name="-pre-build" depends="preBuild" />
<target name="-pre-compile" depends="preCompile" />

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


and build.gradle includes project's build.xml in the following way:

ant.property(file: 'local.properties')

configurations {
    sdkDir = ant.properties['sdk.dir']
}

ant.importBuild "build.xml"


When I run this script with "release" target, I get the following error from Android's build.xml file:

[ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':-build-setup'.
[ERROR] [org.gradle.BuildExceptionReporter] Cause: The following error occurred while executing this line:
[ERROR] [org.gradle.BuildExceptionReporter] Target "${build.target}" does not exist in the project "LibA".


which is caused by line 466 (the one containing "subant"):

<!-- compile the libraries if any -->
<if>
    <condition>
        <isreference refid="project.libraries" />
    </condition>
    <then>
        <echo>Building Libraries</echo>
        <subant
                buildpathref="project.libraries"
                antfile="build.xml"
                target="${build.target}"
                failonerror="true"/>
        <echo></echo>
        <echo>############################################</echo>
        <echo>**** Back to project ${ant.project.name} ****</echo>
        <echo>############################################</echo>
    </then>
</if>


So, the question is: does anybody know how to get rid of that error or how to properly use Android's build.xml in Gradle?

Gradle-android-plugin is broken at the moment for android sdk >= r14 and thus I have resigned from depending on it. I use sdk tools r15.

UPDATE:

It seems that neither

<target name="-set-release-mode" depends="-set-mode-check">

nor

<target name="-set-debug-mode">

is being called in Android's build.xml file, but I don't know why.

Kaye answered 6/12, 2011 at 11:14 Comment(0)
T
1

I don't know anything about the specifics of this environment, but the error message means that an expected property - build.target - is not defined.

I notice that in your project properties file you have this:

# Project target.
target=android-5

Does it work if you change it to this?

# Project target.
build.target=android-5
Trexler answered 6/12, 2011 at 12:16 Comment(1)
Thanks for reply. Unfortunately, this is not the case. Target in project.properties is the api version you are targetting, but build.target is rather an ant target which you were running for main project, eg. "release". So it worked when I set it as "build.target=release", but it should be done automatically, if I understand it well.Kaye
D
0

I had the same problem and solved including:

build.target=release

at the end of project.properties, as suggested by Orzech.

Denotation answered 7/5, 2013 at 12:41 Comment(0)
H
0

I know that this is an old post however the question my still arise for someone. The build.target(s) is any target defined for the Ant builder. If you are using Eclipse, you can define the targets as follow:

Menu->Run->External Tools->External Tools Configuration->Targets

There you select the actual targets to be built by Ant.

Notice that if none is defined, Eclipse will force the Help target.

More to be found here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-exttools.htm

Hexateuch answered 10/5, 2014 at 18:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.