'React-Native: ERROR: requires JDK11 or higher. Incompatible major version detected: '8'

after running npm install and trying to build my app I get the following error:

**************************************************************************************************************



ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'



**************************************************************************************************************






FAILURE: Build failed with an exception.

* What went wrong:
Could not dispatch a message to the daemon.

I have no idea how to fix it.



Solution 1:[1]

You need to install the JDK 11

If you already have it, then you might need to review your environmental variables to make sure they are pointing to the right version.

Solution 2:[2]

WORKS ON WINDOWS!

First Step you should install https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html

make sure you install it on the same folder as where the OpenJDK's installed before, mine installed on C:\Program Files\OpenJDK, you can check it on the next step.

Then go search Edit the system environment variables Edit the system environment variables

Click On Environment Variables 2

then change the JAVA_HOME Value location to your JDK 11's Folder you installed before 3

Save it and restart you PC

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RamaProg
Solution 2 Nico Show