Error check ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables

Ahmad Saeed picture Ahmad Saeed · Jul 22, 2019 · Viewed 31.7k times · Source

To generate apk run

 ionic cordova build android

after some process it generate error.

I set user variables

ANDROID_HOME = C:\Users\Zohab Ud Din\AppData\Local\Android\Sdk\build-tools\29.0.1

JAVA_HOME = C:\Program Files\Java\jdk-12.0.2

PATH = ...;C:\Users\Zohab Ud Din\AppData\Local\Android\Sdk\platform-tools

and I didn't add anything in the system variable

my error is

Checking Java JDK and Android SDK versions
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 12.0.2
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\Zohab Ud Din\AppData\Local\Android\Sdk (DEPRECATED)
[ERROR] An error occurred while running subprocess Cordova.



 cordova.cmd build android exited with exit code 1.

Re-running this command with the --verbose flag may provide more information.

Answer

Swati picture Swati · May 7, 2020

Go to PC properties -> Environment Variable -> Use variable for Your_User_name

Add USED variable FOR Your_User_name-> Add New
Variable: JAVA_HOME
Value: C:\Program Files\Java\jdk1.8.0_221

Variable: ANDROID_SDK_ROOT
Value: C:\Users\Your_User_name\AppData\Local\Android\Sdk

Add following paths to the environment variable PATH:

C:\Users\Your_User_name\AppData\Local\Android\Sdk
C:\Users\Your_User_name\AppData\Local\Android\Sdk\platforms
C:\Users\Your_User_name\AppData\Local\Android\Sdk\platform-tools
C:\Program Files\Java\jdk1.8.0_221
C:\Gradle\gradle-6.3\bin