5

I created an Android project a few months ago and now have to automate the build process with Hudson. The Android dev guide mentions a build.xml file that gets created when you generate a project (http://developer.android.com/guide/developing/other-ide.html) but I dont see one in my project. Will I have to create this by hand or can I run a command to generate it?

Eno
  • 10,730
  • 18
  • 53
  • 86

3 Answers3

11

The ADT plugin doesn't generate an Ant file.

The android command will generate an Ant file when you create a new project from the command line by calling android create project. You could create an example project and copy the build.xml, build.properties and local.properties files from that directory.

Alternatively, you can just copy the build.xml template directly from $ANDROID_HOME/tools/lib/build.template then just change the project name.

Then just create a build.properties file — it's where you place any Ant property overrides.
Also you need a local.properties file, but don't check that into source control — this is where you specify your $ANDROID_HOME directory by setting the sdk.dir property.

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
  • Silly question. If `local.properties` isn’t in source control, what are you supposed to do when you check out the project? – Josh Lee Mar 17 '10 at 21:13
  • Do I *need* a build.properties file? I dont know - can you give me an example of where I would need it? Basically this project was created using the ADT plugin but now I need to automate the build in Hudson, so I need to figure out how to get it to build over there. – Eno Mar 22 '10 at 01:44
  • No, by default it's empty when the `android` tool creates it (just with a bunch of comments demonstrating how you could use that file). – Christopher Orr Mar 22 '10 at 12:42
10

The following will generate a build.xml file as well as a local.properties file if one does not exist in your project.

android update project --path <path to your project directory>

Alex
  • 131
  • 1
  • 5
3

You can use these steps below:

  • Open command line
  • Go to: <path/to/android sdk/tools>
  • Run: $ android update project --path /path/to/my-project => it will generate build.xml and local.properties
  • Create file: ant.properties with two line below

    key.store=path/to/keystore
    key.alias=alias name
    
  • Open build.xml and rename project name if need

  • Run as ant build (debug, release, etc...)

Community
  • 1
  • 1