Flame of udun
Flame of udun

Reputation: 2237

sudo ionic run android not working

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.

Details:

ANDROID_HOME: /home/user/Android/Sdk $PATH: /home/user/Android/Sdk/tools:/home/user/Android/Sdk/platform-tools

Please help! This is driving me up the wall!

Upvotes: 0

Views: 369

Answers (1)

Flame of udun
Flame of udun

Reputation: 2237

Credit for this goes to @heemayl on AskUbuntu.

https://askubuntu.com/a/783805/247116

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

Upvotes: 1

Related Questions