ANDROID_HOME is not set and "android" command not in your PATH

did you have already put this on ~/.bash_profile

export ANDROID_HOME="/YOUR_DIRECTORY/android/sdk"

I finally solved it. It was on my users path but not the root users path. I have to run these commands as a root user. I had to edit my root users .bash_profile file.

Are you running bash as your shell?
Did you check file permissions in your sdk?
Have you tried to rm platofrms and then re-add?

Im running in bash. I have not checked the file permissions on the sdk. I have this same problem with other areas aswell. I have to run most command as the root user e.g. npm install. It gets tedious after a while. I will try adding and removing the platforms.

On Ubuntu, I don’t install node as sudo, I always use nvm and since I started to do it I have less problems with node. Same thing with the sdk, I have yet to find a good reason for using sudo for Ionic/Cordova dev. It’s a pity that Ionic docs uses sudo.

In Ubuntu, do all the commands also root
sudo su
gedit ~/.bash_profile

export ANDROID_HOME=/root/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Bad advice, it’s not required and it’s like playing with fire, see my answer above.

Hi donny,

   Update the android sdk if u required  :)
1 Like

Follow this link to define android global and fix the problem (macosx)

thanks a lot @gmarziou indeed removing the platform and adding it back again did the trick :wink:

1 Like

Thank you, this solution I served :grinning:

Adding this to your .bashrc file works great as well

export JAVA_HOME=$/usr/lib/jvm/java-8-oracle

export PATH=${JAVA_HOME}/bin:$PATH

export ANDROID_HOME=~/Android/Sdk

export PATH=$ANDROID_HOME/platform-tools:$PATH

export PATH=$ANDROID_HOME/tools:$PATH

When I play command ionic cordova build android its not found Android Sdk Path to build APK, But I configured AndroidSdk path, please help

Android Studio project detected
Discovered plugin "com-badrit-base64" in config.xml. Adding it to the project
Installing "com-badrit-base64" for android
Discovered plugin "cordova-plugin-geolocation" in config.xml. Adding it to the project
Installing "cordova-plugin-geolocation" for android
(node:4219) UnhandledPromiseRejectionWarning: CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Detected 'adb' command at /usr/bin but no 'platform-tools' directory found near.
Try reinstall Android SDK or update your PATH to include valid path to SDK/platform-tools directory.
    at /home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/lib/check_reqs.js:287:27
    at _fulfilled (/home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/node_modules/q/q.js:854:54)
    at /home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/node_modules/q/q.js:883:30
    at Promise.promise.promiseDispatch (/home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/node_modules/q/q.js:816:13)
    at /home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/node_modules/q/q.js:877:14
    at runSingle (/home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/node_modules/q/q.js:137:13)
    at flush (/home/nazrul/Development/Projects/ionic/mhrmobile/platforms/android/cordova/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)
(node:4219) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4219) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.