Failed to start aapt command - continues to return "SDK tools for Android SDK"

What I'm trying to do: Install the Android build tools on Mac OSX so that I can use the aapt command to crunch / process some images for testing

What I've done:

  • Android SDK installed using brew
  • Run the android command to open the SDK manager
  • Used Manager to install SDK tools (22.3), Platform-tools SDK (19), Build-tools SDK SDK (19) and Android 4.4
  • I checked that the tools were added to the default location when using brew.

What happens: Running aapt or aapt v always returns Use the 'android' tool to install the "Android SDK Build-tools".

I also tried updating tools with android update , but it still does not work.

EDIT: Running the full path to aapt v . I assume I have a problem with my PATH , which I still need to solve

Any suggestions on what to do next will be greatly appreciated.

+5
android
source share
1 answer

I am sure that the Android SDK is not trying to change your PATH variable for you. If you want to be able to run the SDK tools without specifying the full path, you will need to add the folder (s) containing them to your PATH one at a time.

You can do this by editing ~/.bash_profile and adding such a line (or by editing an existing line if you already have one):

 export PATH="$PATH:/PATH/TO/android-sdk-macosx/build-tools/17.0.0" 

Alternatively, you can simply specify the full path to the tool when it is called, for example:

 /PATH/TO/android-sdk-macosx/build-tools/17.0.0/aapt v 

I'm not sure if this happens with aapt , but it can be useful for disambiguation if multiple versions of the tool are installed. To find out which version of the command bash resolves with, you can usually find out by running which , for example:

 which aapt 

EDIT

There were a lot of good comments in this answer, including Jared's great suggestion to dynamically add last paths to the path . I redefined its code in pure 3.x bash, this is what is currently in my ~/.bash_profile . First, be sure to set ANDROID_HOME :

 export ANDROID_HOME="$HOME/Library/Android/sdk" #Set this to the path to your Android SDK if it not in the default location 

Then (if you are using bash):

 BUILD_TOOLS=($ANDROID_HOME/build-tools/*) ANDROID_LATEST_BUILD_TOOLS="${BUILD_TOOLS[@]:(-1)}" export PATH="$PATH:$HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_LATEST_BUILD_TOOLS" 

Alternatively, here is a version of POSIX that should work in any shell:

 ANDROID_LATEST_BUILD_TOOLS=$(ls -r ${ANDROID_HOME}/build-tools|head -1) export PATH="$PATH:$HOME/bin:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/$ANDROID_LATEST_BUILD_TOOLS" 
+22
source share

All Articles