Ionic cordova run android error related to environment variables

Hello all,

I am very beginning with Ionic and I get troubles to set up properly the coding environment. I carefully followed instructions from an Openclassroom tutorial but when I tried to run my 1st project I got this basic error:

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Users\Anthony\AppData\Local\Android\Sdk (recommended setting)
ANDROID_HOME=C:\Users\Anthony\AppData\Local\Android\Sdk (DEPRECATED)
Requirements check failed for JDK 8 (‘1.8.*’)! Detected version: 12.0.2
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.

I passed hours on different forums to solve it but nothing worked on my side even if the error message was identical (installing another version of JDK, changing environment variables, …). I am going out of ideas about it… Did anyone get similar issues and suceedeed in fixing it? Below are my info:

Ionic:
Ionic CLI : 5.4.5 (C:\Users\Anthony\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.11.4
@angular-devkit/build-angular : 0.801.3
@angular-devkit/schematics : 8.1.3
@angular/cli : 8.1.3
@ionic/angular-toolkit : 2.0.0

Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 4 other plugins)

Utility:
cordova-res : 0.8.1
native-run : 0.2.9

System:
Android SDK Tools : 26.1.1 (C:\Users\Anthony\AppData\Local\Android\Sdk)
NodeJS : v12.13.0 (C:\Program Files\nodejs\node.exe)
npm : 6.12.0
OS : Windows 8.1

Thanks a lot in advance !
Silver

1 Like

install JDK 8 its mismatching download it following link

Requirements check failed for JDK 8 (‘1.8.*’)! Detected version: 12.0.2

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Thanks for the answer, I ever have the same exact 1.8 version of JDK installed as you told me but it is not working. Message error evokes JAVA_HOME variable environment so I tried to set several values but it is not solving the issue:

JAVA_HOME = C:\Program Files\Java\jdk1.8.0_231
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_231\bin
JAVA_HOME = C:\Program Files\Java\jdk-12.0.2

It is not either related to too long path because I am using default values and I created the ionic project at hard drive root level.

Any other idea?

1 Like

I have same here.

Did you find a way to solve the problem?

Non rien à faire, j’ai laissé tomber faute de solution. Bonne chance

Currently Cordova supports Java 1.8. But it does not mean that android supports only java 1.8. Just switch to capacitor … I am using java 16 with capacitor build with gradle 7 …App also somewhat faster than before and performance optimisation is good…
Refer Capacitor - build cross platform apps with the web for more details…Spending a considerable amount of time for App’s compatibility and durability don’t affect your development.Good luck…Happy coding