5

I get the same issue as in this question when I do react-native run-android. I think it wants java 11 but I want to continue with 1.8. How can I do it?

Android Studio - 'com.android.internal.application' Java 11 - fix gradle projects not visibile in Android studio

selcukctn
  • 233
  • 3
  • 13
  • It clearly says that you can't use java 1.8 . To continue with JDK 11 , go to Project Structure > SDK location > Jdk location was moved to Gradle Settings > Gradle JDK drop down menu > Select "Embedded JDK". – LegendSayantan Apr 07 '22 at 12:26
  • when i change it as said ," Task :react-native-gradle-plugin:compileKotlin 'compileJava' task (current target is 1.8) and 'compileKotlin' task (current target is 11) jvm target compatibility should be set to the same Java version." this error not fixed – selcukctn Apr 07 '22 at 12:38

4 Answers4

1

what you need to do;

  1. log into my computer
  2. right click and select properties
  3. enter advanced system settings
  4. add new path name: JAVA_HOME
  5. select the java 11 jdk location and save it

or

  1. open cmd for adminstator
  2. setx JAVA_HOME -m "path"

After doing all of them, delete your old React Native project and install a new one.

or

  1. open project with android stiduo
  2. find node_moduls -> react-native-gradle-plugin -> build.gradle -> change java 1.8 to java 11.0
selcukctn
  • 233
  • 3
  • 13
1

What you need to do:

org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk-11.jdk/contents/Home
Nicky
  • 67
  • 5
  • Answer needs supporting information Your answer could be improved with additional supporting information. Please [edit](https://stackoverflow.com/posts/76246028/edit) to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](https://stackoverflow.com/help/how-to-answer). – moken May 15 '23 at 12:15
1

if you need to upgrade jdk, android studio provides a quick way to do it File ->Setting ->Build,Execution,Deployment ->Build Tools ->Gradle In Gradle JDK selected version you want

ninh312
  • 39
  • 4
0

Try following commands:

nano ./zshrc

Find JAVA_HOME and replace with your v11 java path. You can find the path here:

/usr/libexec/java_home -V

Save the file, re-launch the terminal and try again.

flowey
  • 1