1

I hope someone can help me out with this problem. I am using an Ant Build to compile my java code but I get the following errors:

Buildfile: <PATH>

BUILD FAILED
<PATH>build.xml:55: sdk.dir is missing. Make sure 
    to generate local.properties using 'android update project' or to inject it
    through the ANDROID_HOME environment variable.

Total time: 345 milliseconds

I am using eclipse.

David W.
  • 105,218
  • 39
  • 216
  • 337
user1706083
  • 11
  • 1
  • 2

2 Answers2

6

There are two solutions to this problem, as described in the error message:

  1. Set the value of the sdk.dir variable in the local.properties file in the root directory of your Android project. This needs to point to the location of your Android SDK installation. For example, I have the following line in mine:

    sdk.dir=/usr/local/bin/android-sdk-linux

    You can do this manually or use the android update project command to generate it for you.

  2. Alternatively, you can set the ANDROID_HOME environment variable in your .bashrc file in your home directory. You can do this by adding something like the following line:

    export ANDROID_HOME=/usr/local/bin/android-sdk-linux

    Note that you will need to source your .bashrc file or close your console window and reopen it.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • I can't find the command `android` anywhere. I've tried `locate android`. Seems like a simple mistake, but it's bugging me. On Ubuntu. – Jason Aug 14 '13 at 07:42
  • @Jason Have you installed the Android SDK? If so, `android` is located in the `tools` subdirectory where you installed it. On my development machine, I set `ANDROID_HOME` as explained in my answer here and I add `$ANDROID_HOME/tools` and `$ANDROID_HOME/platform_tools` to `PATH`. – Code-Apprentice Aug 15 '13 at 00:52
  • @Code-Apprentice is it platform_tools or platform-tools? – FrEaKmAn Nov 15 '14 at 13:16
0

Can't tell without seeing your build.xml file. However, the message looks very detailed. It says you need to generate a "local.properties" file, probably to set where sdk.dir is located.

In Ant, you can have a properties file that sets properties your Ant build.xml file uses. It says you can use android update project to create this file. Again, it's hard to say without knowing what your build.xml looks like, what project you're trying to build, etc.

A quick Google pointed me to this page.

David W.
  • 105,218
  • 39
  • 216
  • 337