Error PATH Android Ionic Cordova

Asked

Viewed 642 times

1

Well, I have installed Ionic in the new version, and android studio normally and even these days worked. Now when I went to build, I returned these two errors:

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.

Then I checked if my environment variables were ok, and giving echo $ANDROID_HOME, I get '/home/Willian/Android/Sdk '. It’s exactly as it was when it worked, but now it can’t find the sdk.

I use linux Mint Cinnamon. Someone can give me a hand on this. Note: I saw several related questions, but none of them fixed this problem. Thanks in advance.

  • You could change the question by putting the result of this command: cat /etc/Environment?

1 answer

1

This is because the path to the Android Sdk is not set correctly. Check the correct path to the Sdk, tools, Platform-tools, Emulator and Android build-tools.

Please note that the recommended setting for Ionic has changed a bit. Now the recommended notation is as follows:

ANDROID_SDK_ROOT=/home/username/Android/Sdk (recommended setting)
ANDROID_HOME=/home/username/Android/Sdk (DEPRECATED)

On Linux or Mac OS X set the path in ~/. bashrc, ~/. bash_profile :

export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/build-tools

At the end, after saving the configuration, do not forget to give the command:

source ~/.bashrc

or in other cases

source ~/.bash_profile

For Windows users, check the global variables.

  • If I use ANDROID_SDK_ROOT build error asking ANDROID_HOME. It on the website when it says that updated the variables, it is only the path and not the name. When I export ANDROID_HOME the same time I will build it, it works .

  • Yes the focus is on the path, the new notation is just a recommendation. According to the documentation: Ionic. If the answer is correct, please mark it as such.

  • But it’s not correct. What you asked me to do didn’t help. The error is only fixed when running with SUDO SU, the same way it is today.

  • The ideal is not to use sudo su for this. What I imagine you may not have realized differently is that you have: /home/username/Android/Sdk the whole path, not just the end /Android/Sdk.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.