M. Mariscal
M. Mariscal

Reputation: 1328

Failed to find 'ANDROID_HOME' & 'android' command in your 'PATH'

I get this error:

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

This happens because I have on .bashrc the $ANDROID_HOME and $PATH set up, but when I run sudo ionic cordova build --release android doesn't detect it to me. What should I do?

Upvotes: 0

Views: 236

Answers (1)

Derlin
Derlin

Reputation: 9891

My guess is that your sudo is not configured to keep the PATH (see env_keep in sudoers). So when running a command using sudo, there is not ANDROID_HOME defined anymore.

A quick way to find out is to run sudo env | grep -i android.

To solve the problem, many ways:

  1. change the sudo setting so your PATH environment variable is left unchanged (using env_keep in settings, google is your friend);
  2. define the ANDROID_HOME variable in /root/.profile or /etc/profile, etc.
  3. etc.

Upvotes: 2

Related Questions