How to use ant to build with android

16,921

I also had the same problem.
My problem problem got solved by the following command.

android update project --path . --subprojects --target android-19


ANT will automatically set your sdk.dir into correct one.
Don't put anything inside your local.properties.

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.

# location of the SDK. This is only used by Ant
# For customization when using a Version Control System, please read the
# header note.
Share:
16,921
user1796624
Author by

user1796624

Updated on July 26, 2022

Comments

  • user1796624
    user1796624 almost 2 years

    I want to set up a ant build for my project. I found a tutorial saying that I need to write the following command in order to prepare for ant build:

    android update project -p 
    

    then I get the result

    Updated local.properties
    Updated file ./proguard-project.txt
    It seems that there are sub-projects. If you want to update them
    please use the --subprojects parameter.
    

    so If I try

    android update project -p . --subprojects
    

    then I get:

    Updated local.properties
    Updated file ./proguard-project.txt
    Error: The project either has no target set or the target is invalid.
    Please provide a --target to the 'android update' command.
    

    and if I try

    ant release
    

    I get

    sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var
    

    Can some one please help me in setting up the project with ant. Thanks

  • neodymium
    neodymium about 10 years
    I have my project.properties file with a line: target=android-18 and also have something similar to what you describe in the manifest.xml file, however I am getting the same message as the OP. "It seems that there are sub-projects. If you want to update them please use the --subprojects parameter."
  • Dheeraj Vepakomma
    Dheeraj Vepakomma over 9 years
    The target should be specified as: --target android-19.