Ahmed Wannén
Ahmed Wannén

Reputation: 31

Failed to find 'ANDROID_HOME' environment variable. Despite it's correctly set

When i run

$ionic cordova build android

build failed with this error :

cordova build android 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. [ERROR] An error occurred while running subprocess cordova.

Despite when i run :

cordova requirements

I get this results :

Requirements check results for android:

Java JDK: installed 1.8.0

Android SDK: installed true

Android target: installed android-29,android-28,android-27,android->26,android-25,android-24,android-23,android-22,android-21

Gradle: installed /usr/share/gradle/bin/gradle

EDIT : i'm using Ubuntu

EDIT : SOLVED BY running SUDO -E ionic cordova build android

Upvotes: 3

Views: 5316

Answers (2)

Vinay sharma
Vinay sharma

Reputation: 745

Type these commands in the console -

export ANDROID_HOME=$HOME/Android/Sdk (Your SDK path)

export PATH=$PATH:$ANDROID_HOME/tools

export PATH=$PATH:$ANDROID_HOME/platform-tools

To make it permanent for the current user, add it to the ~/.bashrc file (open it in terminal through vim ~/.bashrc)

Upvotes: 2

Ira Watt
Ira Watt

Reputation: 2135

Your environmental variables are set up incorrectly. Go on your windows/mac search and look up 'environmental variables'. Click edit environmental verifiable then click 'environmental verifiable' then add ANDROID_HOME like so

enter image description here

Upvotes: 1

Related Questions