1

Trying to set up react-native development environment with android studio

I have a fault I don't know what to do with it...

Here is the run and feedback from machine:

npx react-native run-android (from the created project folder)

It gives me back the following:

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 903 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Launching emulator...
info Successfully launched emulator.
info Installing the app...

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\projects\projectfour\android\settings.gradle'

* What went wrong:
Could not compile settings file 'C:\projects\projectfour\android\settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 60

  java.lang.IllegalArgumentException: Unsupported class file major version 60
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:196)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:177)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:163)
        at groovyjarjarasm.asm.ClassReader.<init>(ClassReader.java:284)...

...

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 801ms

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\projects\projectfour\android\settings.gradle'

* What went wrong:
Could not compile settings file 'C:\projects\projectfour\android\settings.gradle'.
> startup failed:
  General error during semantic analysis: Unsupported class file major version 60

setting file for gradle:

rootProject.name = 'projectfour'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'

I have jdk16... I saw posts where it was advised to go to jdk8... these posts were made couple of years ago...

I tried also: ./gradlew.bat installDebug gradlew.bat app:installDebug gradlew clean

All with the same result. I followed this doc: https://microsoft.github.io/react-native-windows/docs/getting-started and this one: https://reactnative.dev/docs/environment-setup

Cannot make it work on my comp, although on other one I had no such difficulties... Somehow

bugthefifth
  • 161
  • 15
  • 1
    set the JAVA_HOME to explicitly use the version you need in the environment-setup if you run `java --version` and the system java is displayed, try this https://stackoverflow.com/questions/21964709/how-to-set-or-change-the-default-java-jdk-version-on-macos – raddrick Jul 07 '21 at 06:09

1 Answers1

1

Try installing JDK8 and setting the environment variable JAVA_HOME to the JDK8 path

  • I thought about it. I didn't try it because I moved on with expo... I will come back and give it a try. It honestly should work. I just think it's really weird, because we are already at jdk 17. So I would think jdk 8 is a little outdated... I thought, there are might be different solution to this... – bugthefifth Apr 15 '21 at 19:21
  • Oh... and I searched for this particular fault... I don't remember exactly, but there were plenty of solutions for this fault and I tried them and they didn't work... And then I decided to move on with expo, but ask question here, may be somebody will have a better idea. Thank you for helping. And good luck with stack overflow! – bugthefifth Apr 15 '21 at 19:27
  • Once I check I will definitely set your answer as right... – bugthefifth Apr 15 '21 at 19:29
  • Well, JDK 8 is still very widely used, and I think the gradle version of a react native project is too old to work with newer jdk versions – Sebastian Breit Apr 30 '21 at 18:59
  • hmm... That's interesting... so why a modern react-native and its component which emulates also modern phones asks for old gradle, which on its own asks for the old version of jdk... Just probably so many elements that it is difficult to keep them all up to date? I didn't forget about your answer, I just didn't have time to try it out. And I cannot just blindly to set it as right, so I might confuse other people, if somehow it doesn't help. My sincere apologies. – bugthefifth May 11 '21 at 08:57
  • No problems, dude, I don't really know the specifics, but I guess if it ain't broke, don't fix it ;) – Sebastian Breit May 15 '21 at 18:53