Android_home path

Hi all,

I know this topic shows up here a lot. I’ve been reading this forum as well as stackoverflow and have followed the directions closely but can’t seem to configure my path correctly. OSX

When I input: ionic build android I get the following error.

[Error: Android SDK not found. Make sure that it is installed. If it is not at the default location, set the ANDROID_HOME environment variable.]
ERROR building one of the platforms: Error: /Users/work/dukana-repo/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project

in: nano ~/.bash_profile

I added:
export ANDROID_HOME=/Applications/android/sdk export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home export ANDROID_HOME=~/.android export PATH=$ANDROID_HOME/tools:$PATH

according to android studio the sdk location is: /Applications/android/sdk

I read online to add the SDK version in the path but this caused a great deal of problems.

I read somewhere to use brew to add gradle. I then read the GRADLE_HOME should be /usr/local/Cellar/gradle/2.7/libexec but adding this to the bash profile didn’t seem to work.

I think I’ve over read on the topic and as you all may be able to tell I haven’t worked with android before. If some angel could help me sort everything out I’d be eternally grateful. I have been mostly following directions from:

Thank you,


before adding everything you find on the internet to system files^^ --> you can set the env variable temporary for your shell/bash instance.

open a new shell --> run “export ANDROID_HOME=PATHTOSDK”

In your codeblock your set the correct path in the first line. but you overwrite it in the third one i think…

after you run the command above you can try to build your app in this shell window.

Thanks for the speedy reply. I followed your instructions.

  1. I ran export ANDROID_HOME=/Applications/android/sdk

  2. I moved to my folder then ran ionic build android

  3. For the first time I got a new error message:
    add to body class: platform-android* *Running command: /Users/work/dukana-repo/platforms/android/cordova/build* *[Error: Please install Android target: "android-22".* *Hint: Open the SDK manager by running: /Applications/android/sdk/tools/android* *You will require:* *1. "SDK Platform" for android-22* *2. "Android SDK Platform-tools (latest)* *3. "Android SDK Build-tools" (latest)]* *ERROR building one of the platforms: Error: /Users/work/dukana-repo/platforms/android/cordova/build: Command failed with exit code 2* *You may not have the required environment or OS to build this project* *Error: /Users/work/dukana-repo/platforms/android/cordova/build: Command failed with exit code 2

  4. I navigated to the sdk through finder and read through the readme again.

  5. Went back and ran android

  6. The command wasn’t recognized. I reread your response and saw that you thought the third line may be in conflict with the first so I removed the third line from my bash_profile. I then added paths to the build-tools, platforms, & platform-tools.

export ANDROID_HOME=/Applications/android/sdk export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home export PATH=/Applications/android/sdk/platform-tools export PATH=/Applications/android/sdk/platforms export PATH=/Applications/android/sdk/build-tools

  1. Went back and tried android again with no luck.

  2. Opened up android studio > SDK manager I checked to make sure the necessary components were present. Installed were as follows:
    Android SDK Tools 24.4.1
    Android Build-tools 23.0.2
    SDK Platform 23
    Documentation for Android SDK
    Sources for Android SDK
    Android Support Repo
    Google Repo

I added:
Android SDK Platform-tools 23.0.1
Android Build tools 22.0.1

  1. Then ionic wasn’t recognized in the folder so I went back to the bash_profile and cleared it out. I opened a new shell and ran export ANDROID_HOME=/Applications/android/sdk

  2. navigated to folder ran ionic build android and got the first error message.
    I can’t seem to get android recognized. It’s getting frustrating because it shouldn’t be this complicated from my understanding. iOS is working totally fine and it was easy to set up.

there is no command “android” at all… install sdk build.tool for version 21 and 22 not only 22.0.1

Thanks for your assistance. I had to download an older version of the SDK.

I don’t know if you fixed it, but you should check path (folder) permissions, if ANDROID_HOME doesn’t have permission to your user, ionic build android won’t work.

It’s not recommended but you can do for know $sudo chmod -R 777 $ANDROID_HOME

You need to install SDK tools package from and replace it in your sdk folder instaed of “tools” folder.