Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 552
Orzech Avatar asked Dec 06 '11 11:12

Orzech


1 Answers

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
like image 168
sudocode Avatar answered Oct 16 '22 06:10

sudocode