I have faced this “Requirements check failed for JDK 8” error in Ionic Studio when I tried to run my newly created Ionic App in Android Device. The exact error was the following.
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 12.0.1
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.
This error happens because of the difference between the already installed version of JDK and what Cordova required to build the App. In my case the already installed JDK version is
12.0.1. and Cordova required JDK 8.
As it’s clear from the above reason, we need to install JDK 8 to run Ionic App successfully. We don’t need to uninstall the previously installed JDK version, we can keep both versions.
1. Download & Install JDK 8 from Oracle official Website.
2. Set JAVA_HOME environment variables to the JDK 8.
In Mac, run the following command to set environment variables.
touch ~/.bash_profile; open ~/.bash_profile
The above command will open your Text Editor with
.bash_profile file. Add the following lines in this file. Don’t forget to change the paths according to your save locations of JDK 8 and Android SDK. In the following code, I’ve added the default paths.
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home export JAVA_HOME; ANDROID_HOME=/Users/YOUR_USERNAME/Library/Android/sdk export ANDROID_HOME; ANDROID_SDK_ROOT=/Users/YOUR_USERNAME/Library/Android/sdk export ANDROID_SDK_ROOT;
3. Save the .bash_profile file and Quit (Command + Q) in Text Editor.
4. Run command
Now close your terminal and rebuild the project. And the “Requirements check failed for JDK 8” error should be fixed. If you still face any problem, feel free to ask in the comments section. 🙂
You can also find other useful helping articles, code snippets and tutorials in our Coding Articles & Tutorials Knowledge Base.