react-native: [Android] Gradle fails with `> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 62`
Description
warn Package react-native-navigation contains invalid configuration: "dependency.assets" is not allowed,"dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings remapped class cache for 2b2v1krlox0a6mjvnk5eb71wr (/Users/tenna/.gradle/caches/6.3/scripts-remapped/settings_1rtjkco7nerckjkpaki5l1zp5/2b2v1krlox0a6mjvnk5eb71wr/settingsdeec0faa97453e2ce860d75e6bf1604b).
> Could not open settings generic class cache for settings file '/Users/tenna/Desktop/aitem/android/settings.gradle' (/Users/tenna/.gradle/caches/6.3/scripts/2b2v1krlox0a6mjvnk5eb71wr/settings/settingsdeec0faa97453e2ce860d75e6bf1604b).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 62
* 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 649ms
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 app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings remapped class cache for 2b2v1krlox0a6mjvnk5eb71wr (/Users/tenna/.gradle/caches/6.3/scripts-remapped/settings_1rtjkco7nerckjkpaki5l1zp5/2b2v1krlox0a6mjvnk5eb71wr/settingsdeec0faa97453e2ce860d75e6bf1604b).
> Could not open settings generic class cache for settings file '/Users/tenna/Desktop/aitem/android/settings.gradle' (/Users/tenna/.gradle/caches/6.3/scripts/2b2v1krlox0a6mjvnk5eb71wr/settings/settingsdeec0faa97453e2ce860d75e6bf1604b).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 62
* 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 649ms
at makeError (/Users/tenna/Desktop/aitem/node_modules/execa/index.js:174:9)
at /Users/tenna/Desktop/aitem/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (/Users/tenna/Desktop/aitem/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Users/tenna/Desktop/aitem/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
I have done everything this page said: https://reactnative.dev/docs/environment-setup. M1 Mac
Version
0.7
Output of npx react-native info
warn Package react-native-navigation contains invalid configuration: “dependency.assets” is not allowed,“dependency.hooks” is not allowed. Please verify it’s properly linked using “react-native config” command and contact the package maintainers about this. info Fetching system and libraries information… System: OS: macOS 12.5 CPU: (8) arm64 Apple M1 Memory: 114.81 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.11.0 - ~/.nodebrew/current/bin/node Yarn: 3.2.3 - ~/.yarn/bin/yarn npm: 8.0.0 - ~/.nodebrew/current/bin/npm Watchman: 2022.09.26.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.0.1/14A400 - /usr/bin/xcodebuild Languages: Java: 18.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: ^18.2.0 => 18.2.0 react-native: ^0.70.1 => 0.70.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
I can give an access to the repository if that’ll help.
Snack, code example, screenshot, or link to a repository
I can give an access to the repository if that’ll help. I am struggling with errors that coming on and on for days… Please help…
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 33 (2 by maintainers)
Try this https://stackoverflow.com/questions/74695402/bug-exception-in-phase-semantic-analysis-in-source-unit-buildscript-unsup/74695403
Changing the distribution url in gradle-wrapper.properties to 7.6
What’s your Gradle versions? You can find it inside the
android/gradle/gradle-wrapper.propertiesfile.I believe you’re on a old Gradle version which doesn’t support Java 18. As an alternative, movign to JDK 11 should solve your issue.
BUG! exception in phase ‘semantic analysis’ in source unit ‘BuildScript’ Unsupported class file major version 65
what should i do ? also having this error too - "Your project’s Gradle version is incompatible with the Java version that Flutter is using for Gradle. "
Help me to overcome this …
If someone else is still in problems with this, the solution, in my case was to align my version of Gradle with the Java one. There is a compatibility matrix that explains which version of Gradle works with which version of Java. By aligning them, it worked on my env.
For people using Expo trying to build your app locally the “old way” with
expo run:androidornpx react-native run-androidcommands :I came to understand that if you are in a managed Expo app, and you want to build your app locally , expo advises to use the “new way” of building locally with
eas build(as documented here) The major issue for me here is that creating the local build this way witheas buildwill count in your build usage on expo.dev.Moreover,
iosandandroidfolders are generated if you are in a managed workflow , meaning you cannot change the gradle version as advised in this comment for example because this setting will be overriden the next time you perform a build viaeas buildcommandSo, here’s how I managed to run local builds with
expo run:androidorreact-native run-androidThe problem was the gradle version set by Expo was not compatible with the java runtime version installed on my machine
gradleused by Expo, inandroid/gradle/wrapper/gradle-wrapper.properties@abdul-megadraws @nikitaGrynch
SOLUTION:
go to android/gradle/wrapper/gradle-wrapper.properties
Find the distributionUrl variable and change the end path to gradle-7.6-all.zip
What about eas build?
i face same error and I solved my problem install idk 11; follow this AndroidStudio->file->ProjectStructure->click Gradle Settings->choose idk 11
https://user-images.githubusercontent.com/12226661/170825694-d28dc202-d23d-4ed4-a2d8-035d84ad7b58.png
same issue here
Same issue here.
Any solution for React Native Expo ? expo run:android
This doesn’t seem to work anymore, as EAS just decides to use 7.5.1 no matter how many times
gradle-wrapper.propertiesis changed.That works! Thank you!
I’m having the same error: A problem occurred configuring root project ‘LittleLemonNewsletterFinal’.