Ionic ANDROID_HOME is set but still getting errors

I’m new to Hybrid App Development, since a few days I have been fighting with how to build my Ionic App’s APK file. I have tried ionic cordova build --release android as suggested here but I see following errors:

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 then my ANDROID_HOME is set. Please note that I have tried reinstalling both Ionic and Android Studio but still getting the same error.

Installing Android Studio should take care of all of that normally…

Please post your ionic info and cordova requirements output. Right now we don’t even need your OS.

Hi,

Thanks for the reply. ionic info returns:

@ionic/cli-utils : 1.5.0
    Cordova CLI      : 7.0.1 
    Gulp CLI         : CLI version 3.9.1 Local version 3.9.1
    Ionic CLI        : 3.5.0

local packages:

    @ionic/cli-plugin-cordova : 1.4.1
    @ionic/cli-plugin-gulp    : 1.0.2
    @ionic/cli-plugin-ionic1  : 2.0.1
    Cordova Platforms         : android 6.2.3
    Ionic Framework           : ionic1 1.3.3

System:

    Node       : v6.11.0
    OS         : Linux 4.4
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm 
cordova requirements
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-25".

Hint: Open the SDK manager by running: /home/faizan/Android/Sdk/tools/android
You will require:
1. "SDK Platform" for API level android-25
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
Gradle: installed /usr/share/gradle/bin/gradle
Error: Some of requirements check failed
echo $ANDROID_HOME 
/home/faizan/Android/Sdk
echo $PATH
/home/faizan/anaconda2/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/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/faizan/Android/Sdk/tools:/home/faizan/Android/Sdk/platform-tools

However, yesterday, after doing some searches on Stack Overflow, I found that if I can build it by defining ANDROID_HOME within the command .ie.

sudo ANDROID_HOME=/home/faizan/Android PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools ionic cordova build --release android

Is there any fix which I can do in order to prevent from passing variable manually?

Not as long as cordova requirements is not happy.