When I try to run cordova or ionic I keep on getting the error:

Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.

I have android SDK in /opt/android-sdk.
When I echo $ANDROID_HOME it returns /opt/android-sdk correctly.

When I echo $PATH it returns:


So the way I see it I have both paths to platform-tools and tools correctly added to PATH.


When I write android in the terminal it opens the Android SDK manager as it should.

So I started desperate mode and start changing the files: ~/.bashrc & ~/.bash_profile & ~/.profile

I figure they all do the same. Which is setting the ANDROID_HOME env. path and the PATH. But if when I echo $ANDROID_HOME and $PATH all looks fine then what the eck I just start doing anything that I can find.

I nanoed ~/.bashrc with:

export ANDROID_HOME=/opt/android-sdk  

and executed source ~/.bashrc

I nanoed ~/.bash_profile with:


export PATH=${PATH}:/opt/android-sdk/platform-tools:/opt/android-sdk/tools  
export ANDROID_HOME=/opt/android-sdk

and executed source ~/.bash_profile

I nanoed ~/.profile:

# set PATH so it includes user's private bin if it exists  
if [ -d "$HOME/bin" ] ; then  
export ANDROID_HOME=/opt/android-sdk  
export PATH=$PATH:/opt/android-sdk/tools  
export PATH=$PATH:/opt/android-sdk/platform-tools  
export PATH=$PATH:/bin  
export PATH=$PATH:/opt/gradle/bin  
export JAVA_HOME=/usr/lib/jvm/default-java

and executed source ~/.profile

That leaves me thinking something is wrong with android-sdk but actually the Android SDK manager is opening and uploading and displaying the right location on top.

So summing up I am desperately trying everything and this error keeps on popping up. Does anyone have any tip on what should I do next or undo?

  • Thanks a lot to everyone I even got help online and noone could help me. I am just gonna say BYE UBUNTUTUTUTTUUTUT# – Dave Sep 12 '16 at 17:24

I had the same problem after install with umake android.

Solved adding to .zshrc (.bashrc in your case):

export PATH="$PATH:/home/username/opt/android-studio/bin"
export ANDROID_HOME="/home/username/Android/Sdk"

Are you using npm with sudo?

If you installed one as a normal user and the other as sudo you could try to reinstall or add the paths to the root user.

Install node without sudo.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.