2
votes

I am trying to build an ionic project. I have set up environment for ionic and android in ubuntu. But don't know why the following error is showing on terminal ...

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 set up android home as followings ...

userPC:/codes/myApp$ export ANDROID_HOME=/opt/android-sdk-linux
userPC:/codes/myApp$ export ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform_tools
userPC:/codes/myApp$ export ANDROID_TOOLS=/opt/android-sdk-linux/tools
userPC:/codes/myApp$ PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS

my android-sdk-linux is in /opt/ itself. From terminal I can run android command. So, I think environment variable is not the main issue. While I am trying to build ionic project, it shows Failed to find 'ANDROID_HOME' environment variable. I am using Android SDK Build Tools 22 and ionic latest version.

Can anyone tell me how can I solve this issue? I have searches a lot but everywhere I found to setup android sdk and environment variable path correctly. But I already have set up all these things. Thanks!

2

2 Answers

2
votes

I think you are doing everything right except for the bin part.Add ANDROID_HOME environment variable to path and point out the corresponding bin directory as:

1.export ANDROID_HOME=/path/to/android/SDK
2.export PATH=$PATH:$ANDROID_HOME/bin

when you issue studio.sh command on the command line, it looks for the bin directory in the path which contain executables! studio.sh is the one in this case.

For more information,Read this

Hope this was helpful.

1
votes

After long time on search. To make a final fix for this problem
Follow Theses incrustation and it will fix it Correctly

  1. Delete your current installation of node & npm & ionic & cordova

  2. Install nvm follow this install nvm ubuntu

  3. Install node with nvm follow this install node via nvm

  4. Install ionic and cordova

    npm install -g cordova ionic

  5. Never use root to install node ,npm ,ionic or cordova

  6. Set your Android Home

    export ANDROID_HOME=/path/to/android/SDK

    export PATH=$PATH:$ANDROID_HOME/bin

After that its worked fine for my and ionic can see Android SDK home