Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not compile settings gradle React Native

The app worked for me from another machine, now that downloading the files from the repository on another computer gives me this problem

FAILURE: Build failed with an exception.

  • Where: Settings file 'C:\Users\samue\Desktop\MCGPS\TeachAll\android\settings.gradle'

  • What went wrong: Could not compile settings file 'C:\Users\samue\Desktop\MCGPS\TeachAll\android\settings.gradle'.

    startup failed: General error during semantic analysis: Unsupported class file major version 57

like image 261
Ivan Sandoval Avatar asked Oct 08 '19 20:10

Ivan Sandoval


2 Answers

This is an issue with how Gradle is automating the build and the current version of the JDK installed on your machine, follow these steps to fix it, the react native documentation states you need adoptopenjdk8, however you may have other conflicting JDK versions in the same directory.

Blog post: https://ashirazee.medium.com/react-native-android-failure-build-failed-with-an-exception-908934c3a32b

Step one:

open up your terminal and navigate to /Library/Java/JavaVirtualMachines by typing the following command:

cd /Library/Java/JavaVirtualMachines

after you have done that type ls to see what files are included and take note of the versions.

incase you have one or multiple JDK files present like such:

adoptopenjdk-8.jdk jdk-16.jdk  jdk-8.jdk

then go head and delete them with the following command line :

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-16.jdk 
 
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-8.jdk

the only dependency you need is adoptopenjdk-8.jdk as mentioned in the react native docs

however delete that aswell and reinstall it after you have completed these steps:

sudo rm -rf /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk

after you have done so you can check if the files still exist by typing ls

if the files are deleted.

Step 2:

then run the following commands to insure all other links, plugins and files are deleted as-well from your Library:

run the following :

sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf ~/Library/Application\ Support/Oracle/Java

Step 3:

once you have done the following, reinstall the correct jdk as mentioned in the react native docs like so:

brew install --cask adoptopenjdk/openjdk/adoptopenjdk8

https://reactnative.dev/docs/_getting-started-macos-android

this may say adoptopenjdk-8.jdk is already installed, but go ahead and reinstall install it with:

brew reinstall adoptopenjdk8

enter image description here

At this point the error should be resolved and your build should work.

enter image description here

It is important to note that this is a build error, since react native uses Gradle to build automations, the conflicting of multiple jdk versions can cause your build to fail.

please refer to the following documentation:

https://docs.gradle.org/current/userguide/userguide.html

like image 170
Ali Shirazee Avatar answered Sep 28 '22 01:09

Ali Shirazee


I have solved issue by just opening project in Android studio react native version 0.60.5

like image 34
user12371692 Avatar answered Sep 28 '22 01:09

user12371692