69

I believe I've followed the instructions in the Android SDK, and I'm now trying to build the sample LunarLander (random one picked)

$ cd samples/android-11/LunarLander
$ ant debug
Buildfile: build.xml does not exist!
Build failed

I believe all PATHs are setup correctly. I've done this before in an older Android SDK release and I know I didn't encounter this error, so I'm pretty confused as to what's wrong.

Oh, one more piece of info -- I have only installed the 3.0 platform package, so I'm not sure if that is an error or not.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Kalen
  • 3,106
  • 8
  • 29
  • 42
  • Do you have a `build.xml` in `samples/android-11/LunarLander` directory? – javanna Apr 06 '11 at 20:08
  • just: AndroidManifest.xml, overriding the xml build file with that gave an error as well – Kalen Apr 06 '11 at 20:11
  • stop making it hard for yourself and use eclipse – molleman Apr 06 '11 at 20:13
  • i use xcode, just a personal preference. the project i start will be an ndk one, with most coding being C++.. breakpoints will be inputted via gdb commands directly, as from i can tell theres no integration instructions provided to link ndk-gdb with eclipse from what i've read – Kalen Apr 06 '11 at 20:21
  • I tried all the possible answers but no way till i found this [Answer][1] [1]: http://stackoverflow.com/a/16707758/1752899 – Hossam Ghareeb Jun 23 '13 at 23:19
  • I tried all the possible answers but no way till i found this [Answer][1] [1]: http://stackoverflow.com/a/16707758/1752899 – Hossam Ghareeb Jun 23 '13 at 23:19

3 Answers3

117

You need to execute this command:

android update project --target <your build target> --path <path to LunarLander example>

which will create the needed build.xml within the example directory, then the ant debug command should work.

Take a look here.

*You can use android list targets to choose what build target to use for your project.

ren.rocks
  • 772
  • 1
  • 7
  • 22
javanna
  • 59,145
  • 14
  • 144
  • 125
  • 4
    Using just "target 1" isn't usually a good solution. Execute `android list targets` and select the appropriate target id for the project to build. – Robert Nov 14 '12 at 13:55
  • 4
    Alternatively, you can use `android update project -p `, where is the path of the project (from http://stackoverflow.com/a/15718940/1103747). This form is just a bit more concise and easy to remember. – fouric May 13 '13 at 00:08
  • The android command is localized on $ANDROID_HOME/tools/. For libraries there are other commands. Check it here: http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject – jiahao Apr 21 '14 at 17:31
  • 1
    `android update` was removed in SDK tools 26.0.1: https://stackoverflow.com/a/34955478/895245 – Ciro Santilli OurBigBook.com Oct 28 '17 at 21:28
5

android updated project was remove in SDK tools 26.0.1

Don't use Ant. It is not properly supported anymore. For now, just use Android Studio GUI and create Gradle projects manually.

android update project was finally removed in SDK tools 26.0.1 after a long deprecation period, and fails for example wth:

The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Invalid or unsupported command "update project -p ./bloom -t android-23"

So now I don't know a good way to create a project from the CLI without Android Studio. The best workaround I have so far is to create a template project with Android studio, and he copy it around with a helper script as described at: How to create android project with gradle from command line?

Also I haven't managed to easily import an existing Ant project to Gradle: Doing an Ant Build on Android Studio so I just copy the sources around for now.

Before 26.0.1

When starting a new project you can use:

android create project \
    --target 1 \
    --name MyName \
    --path . \
    --activity MyActivity \
    --package com.yourdomain.yourproject

which creates the build.xml automatically.

Those demo projects contain only gradlew files: I wish Google could use only one of Ant or Gradle for everything.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
-6

Please install at ubuntu openjdk-7-jdk

sudo apt-get install openjdk-7-jdk

on Windows, try find find openjdk.

Undo
  • 25,519
  • 37
  • 106
  • 129
Artmetic
  • 350
  • 2
  • 12