Monday, 11 June 2018

IONIC Build: Failed to find 'ANDROID_HOME' environment variable

Hello All,

When we are creating a build at that time, we may face the following issue:

$ ionic cordova build android


Running command: 

/demoApp/hooks/after_prepare/010_add_platform_class.js /demoApp
  add to body class: platform-android
  ERROR building one of the platforms: Failed to find 'ANDROID_HOME'  environment variable. Try setting it manually.
  Failed to find 'android' command in your 'PATH'. Try to update your 'PATH' to include a path to valid SDK directory.
You may not have the required environment or OS to build this project
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try to update your 'PATH' to include the path to valid SDK directory.




Let us try to fix this issue:

  • First, check whether you have installed Android SDK or not, Install or check to do following steps:
    • Download & unzip the correct version of the Android SDK for your operating system.
    • Configure the ANDROID_HOME environment variable based on the location of the Android SDK. Additionally, consider adding  ANDROID_HOME/tools, and ANDROID_HOME/platform-tools to your PATH.
    • Export the path as follows:


Mac OS X

export ANDROID_HOME=//android-sdk-macosxexport PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools


Linux

export ANDROID_HOME=//android-sdk-linuxexport PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools


Windows

set ANDROID_HOME=C:\\android-sdk-windowsset PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools



    • Now download specific Android platforms.


    • Select the Tools check box.
    • Select the checkbox for the latest Android SDK.
    • From the Extras folder, select the checkbox for the Android Support Library.
    • Click the Install packages... button to complete the download and installation.

Now you are done with it.

Just now run the following commands to create the build.

$ ionic cordova platform rm android

$ ionic cordova platform add android

$ ionic cordova build android


I hope this will fix your issue.

Thanks & Cheers !!!!

No comments:

Post a Comment