1
votes

ANDROID_HOME=C:\Users\tgiak\AppData\Local\Android\sdk JAVA_HOME=C:\Program Files\Java\jdk-9.0.4 (node:11252) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Requirements check failed for JDK 1.8 or greater (node:11252) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Still get this error, re-installed all the npm modules after upgrading Java. I can do nothing more.

2

2 Answers

4
votes

Android SDK does not support JDK 9. It has support for some of JDK 8 features and hence can be used.

Consequentially, Ionic and Cordova apps cannot use JDK 9 for Android platform. You will need to install JDK 8 and reset JAVA_HOME to JDK 8 and try. In order to verify if your setup works, use the command:

cordova requirements

in your project folder.

0
votes

I had the same error with ionic 3.19.1 cordova 8.0.0 when trying the command: ionic cordova build android.

After trying installing jdk1.8.0_162 and uninstalling older versions with no success. I took a look in the code of the check_reqs.js file where the error was thrown and found that checks the java version with the following regex:

/javac ((?:1\.)(?:[8-9]\.)(?:\d+))|((?:1\.)(?:[1-9]\d+\.)(?:\d+))/i and the javac -version command.

With that I could found a javac.exe 1.7 version somewhere in my user directory used by another app that was included in the PATH variable before the newer version and was not listed in the "uninstall a program" window.

I also used the follow command to check the full file name of the first version of javac in the PATH variable

for %i in (javac.exe) do @echo %~$PATH:i

So the solution was to remove that old version directory path from the PATH variable