0

I am trying to build an apk in ionic 2 but while building is getting following error.

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.

After that, I set the environment variable and path. Even though still am getting that error again can anyone please help me how to solve this issue

Vivek Kannan
  • 143
  • 1
  • 2
  • 10

1 Answers1

0

Instruction 1: After adding your ANDROID_HOME, make sure you do the below:

  1. Restart your System or run source ~/.bash_profile

  2. Remove Android platform from your project ionic cordova platform rm android or ionic platform rm android

  3. Add Android platform ionic cordova platform add android

  4. Then ionic cordova run android or ionic run android

Instruction 2: To set your ANDROID_HOME and JAVA_HOME, follow the below steps:

  1. Run command open ~/.bash_profile
  2. Paste the below in the file that opens on your Text editor

export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1 export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

  1. Save - "Command S" or "Ctrl S"
  2. Then Follow the "Instruction 1:" above

NOTE: Make sure you have 24.4.1_1 SDK

Hope this helps.

Victor Ejiogu
  • 1,184
  • 14
  • 23