0

I'm trying to run and install a React Native app, but during the build process I get the following error:

yarn android:

info A dev server is already running for this project on port 8081. info Installing the app... info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/Users/NameUser/.gradle/wrapper/dists/gradle-8.12-all/ejduaidbjup3bmmkhw3rie4zb/gradle-8.12/lib/native-platform-0.22-milestone-27.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled FAILURE: Build failed with an exception. * What went wrong: BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 68 > Unsupported class file major version 68 * 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 793ms error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/Users/NameUser/.gradle/wrapper/dists/gradle-8.12-all/ejduaidbjup3bmmkhw3rie4zb/gradle-8.12/lib/native-platform-0.22-milestone-27.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled FAILURE: Build failed with an exception. * What went wrong: BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 68 > Unsupported class file major version 68 * 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 793ms. info Run CLI with --verbose flag for more details. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 

Java:

java --version openjdk 24 2025-03-18 OpenJDK Runtime Environment (build 24+36-3646) OpenJDK 64-Bit Server VM (build 24+36-3646, mixed mode, sharing) 

Gradle:

gradle --version ------------------------------------------------------------ Gradle 8.13 ------------------------------------------------------------ Build time: 2025-02-25 09:22:14 UTC Revision: 073314332697ba45c16c0a0ce1891fa6794179ff Kotlin: 2.0.21 Groovy: 3.0.22 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 23.0.2 (Homebrew 23.0.2) Daemon JVM: /usr/local/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home (no JDK specified, using current Java home) OS: Mac OS X 15.3 x86_64 

Dir android project:

~/Desktop/project-react-native/android > ./gradlew --version WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/Users/NameUser/.gradle/wrapper/dists/gradle-8.12-all/ejduaidbjup3bmmkhw3rie4zb/gradle-8.12/lib/native-platform-0.22-milestone-27.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled ------------------------------------------------------------ Gradle 8.12 ------------------------------------------------------------ Build time: 2024-12-20 15:46:53 UTC Revision: a3cacb207fec727859be9354c1937da2e59004c1 Kotlin: 2.0.21 Groovy: 3.0.22 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 24 (Oracle Corporation 24+36-3646) Daemon JVM: /Users/NameUser/Library/Java/JavaVirtualMachines/openjdk-24/Contents/Home (no JDK specified, using current Java home) OS: Mac OS X 15.3 x86_64 

Can you give me a hand?

4
  • Don't use the latest Java version, use the Java version that Gradle and the Android Gradle tools require. If I remember correctly that should be Java 21. Check also which Java version is recommended for React Native. Anyway for developing I strongly recommend only to use LTS versions of Jav a. Commented Apr 2 at 20:57
  • You're using Java 24 for some things which produces version 68 compatible class files and then in the Gradle launcher VM you're using Java 23 and it won't know how to read class files past version 67. See: javaalmanac.io/bytecode/versions Commented Apr 2 at 22:00
  • Gradle currently doesn't support Java 24 (class version 68), and neither does whatever does that "semantic analysis" that fails. Commented Apr 3 at 10:19
  • Do you recommend me to install sdkman, for version manager? sdkman.io Commented Apr 4 at 9:19

1 Answer 1

0

The error message you're seeing:

Unsupported class file major version 68 

means that your Java version is too new for the version of Gradle you're using. Specifically:

Major version 68 corresponds to Java 22 But Gradle 8.1.3 does not yet fully support Java 22 

🔧 Solution:

You need to downgrade your Java version to Java 17 or 21, which are stable and widely supported by Android Gradle builds.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.