Search code examples
androidcordovacordova-plugins

Cordova ANDROID_HOME not found even already been added to environmental variables


Lately I can perform cordova commands successfully such as

cordova build --release android

But now it fails, saying ANDROID_HOME not found even I already added it on the windows environmental variables (below image)

enter image description here

I even tried to set the ANDROID_HOME and SDK tools, platform-tools path via windows command running as a administrator even it was already been set on the path.

set ANDROID_HOME=C:\Users\UI-UX-PC1\AppData\Local\Android\Sdk
set PATH=C:\Users\UI-UX-PC1\AppData\Local\Android\Sdk\platform-tools
set PATH=C:\Users\UI-UX-PC1\AppData\Local\Android\Sdk\tools

but no luck at all, any help, ideas please?

below is my cordova app config.xml

<?xml version='1.0' encoding='utf-8'?> <widget id="com.mobile.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Mobile App</name>
    <description>
        Mobile App
    </description>
    <author email="[email protected]" href="https://www.meme.com">
        Meme mobile
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="res/icon/android/icon-36-ldpi.png" />
        <icon density="mdpi" src="res/icon/android/icon-48-mdpi.png" />
        <icon density="hdpi" src="res/icon/android/icon-72-hdpi.png" />
        <icon density="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />
        <splash density="land-hdpi" src="res/screen/android/screen-hdpi-landscape.png" />
        <splash density="land-ldpi" src="res/screen/android/screen-ldpi-landscape.png" />
        <splash density="land-mdpi" src="res/screen/android/screen-mdpi-landscape.png" />
        <splash density="land-xhdpi" src="res/screen/android/screen-xhdpi-landscape.png" />
        <splash density="port-hdpi" src="res/screen/android/screen-hdpi-portrait.png" />
        <splash density="port-ldpi" src="res/screen/android/screen-ldpi-portrait.png" />
        <splash density="port-mdpi" src="res/screen/android/screen-mdpi-portrait.png" />
        <splash density="port-xhdpi" src="res/screen/android/screen-xhdpi-portrait.png" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="res/icon/ios/icon-57.png" width="57" />
        <icon height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
        <icon height="72" src="res/icon/ios/icon-72.png" width="72" />
        <icon height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
    </platform>
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <preference name="AutoHideSplashScreen" value="true" />
    <engine name="ios" spec="^4.5.5" />
    <engine name="android" spec="^5.0.0" /> </widget>

Solution

  • ANDROID_HOME is deprecated now instead of using ANDROID_HOME use ANDROID_SDK_ROOT

    as per Google android documentation -

    ANDROID_SDK_ROOT sets the path to the SDK installation directory. Once set, the value does not typically change, and can be shared by multiple users on the same machine. ANDROID_HOME, which also points to the SDK installation directory, is deprecated.

    If you continue to use it, the following rules apply:

    • If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.
    • If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
    • If ANDROID_HOME is defined but does not exist or does not contain a valid SDK installation, the value in ANDROID_SDK_ROOT is used instead.

    For details follow this link I hope Its work for you