2

I am trying to run a hybrid app on my android phone using ionic using the following command:

sudo ionic run android

However I keep receiving this 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 already added platform tools & tools to PATH updated ANDROID_HOME to point to my sdk root.

The ANDROID_HOME environment variable shows up when I run env and the PATH has the tools and platform tools too. Additionally I can execute android too. It launches the SDK Manager as expected.

Please help! This is driving me up the wall!

7

sudo sanitizes the environment and by default only keeps certain environment variables available with modifying the values of some (e.g. PATH).

You can pass the variable ANDROID_HOME manually:

sudo ANDROID_HOME="/actual/path" ionic run android

Or preserve the current environment:

sudo -E ionic run android

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.