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: https://cordova.apache.org/docs/en/5.4.0/guide/platforms/android/
Thanks for the speedy reply. I followed your instructions.
I ran export ANDROID_HOME=/Applications/android/sdk
I moved to my folder then ran ionic build android
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
I navigated to the sdk through finder and read through the readme again.
Went back and ran android
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.
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
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
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.
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