Ionic says $ANDROID_HOME is not set but it’s set!


#1

Hello,
I’m running Ionic 3 project and trying to run ionic cordova run android --device but it’s returning me an error saying:

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

Even when running ionic cordova run android it produces the same error.
Other information:
echo $ANDROID_HOME : /home/leno/Android/Sdk
I also have $ANDROID_HOME/tools and $ANDROID_HOME/platform-tools in my path:
echo $PATH : /home/leno/Android/Sdk:/home/leno/bin:/home/leno/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/db/bin:/home/leno/Android/Sdk/tools/bin/sdkmanager:/home/leno/Android/Sdk/platform-tools

Running ionic info:

cli packages: (/usr/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 7.1.0 

local packages:

    @ionic/app-scripts : 3.1.4
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.3
    npm  : 5.6.0 
    OS   : Linux 4.10

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : pro

Can someone point to me where the problem is please!


#2

What does ionic cordova requirements return?
You should probably upgrade to cordova-android 6.4.0 if you have current Android tooling (SDK, Studio) installed.


#3
You have been opted out of telemetry. To change this, run: cordova telemetry on.

Requirements check results for android:

Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed 
Please install Android target / API level: "android-26".

Hint: Open the SDK manager by running: /home/siraj/Android/Sdk/tools/android
You will require:
1. "SDK Platform" for API level android-26
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)

Gradle: not installed 

Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle 
in your path, or install Android Studio

Error: Some of requirements check failed

#4

Yeahm upgrade to cordova-android 6.4.0 and try that again.
You probably have to install Gradle from https://gradle.org/install/ as well.