5

I received this error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings remapped class cache for 1a8j0dwq37525yzi9alfmzw3 (C:\Users\Username\.gradle\caches\5.4.1\scripts-remapped\settings_7z9efzwj1mz1b0w35o6u5p4ep\1a8j0dwq37525yzi9alfmzw3\settingsdcd040730888da95d185715568c9cc57).
> Could not open settings generic class cache for settings file 'PATH\android\settings.gradle' (C:\Users\Username\.gradle\caches\5.4.1\scripts\1a8j0dwq37525yzi9alfmzw3\settings\settingsdcd040730888da95d185715568c9cc57).
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 57

Yesterday I tried to add the Google Login Package and received similar errors. Then I pulled a working version from my Github Repository and now I get this error. Already cleaned Gradle, reinstalled Java, deleted Cache, "Restart and delete" with Android Studio... Has anybody an idea?

Thanks in advance

Mare Seestern
  • 335
  • 1
  • 3
  • 13
  • 1
    For Flutter (might help in other frameworks) I have posted an answer on [this](https://stackoverflow.com/a/67541988/12349734) post. – MendelG May 14 '21 at 23:26

6 Answers6

3

Had the same problem. Here's how i solved this.

Go to android > gradle > > wrapper > gradle-wrapper.properties file and find distributionUrl and at the end of that line you'll find gradle-5.2-all.zip kind of gradle version. This version can be diffrent in your case. just change it to latest gradle version. In my case latest version is 6.7 so i changed version like this. Before

distributionUrl=https\://services.gradle.org/distributions/gradle-5.2-all.zip

After

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
Nipun Ravisara
  • 3,629
  • 3
  • 20
  • 35
3

Please Change your distributionUrl (android > gradle > > wrapper > gradle-wrapper.properties) to:


Depend on ion your JDK version(your jdk version and Gradle version should related)...


My JDK: 18

distributionUrl=https://services.gradle.org/distributions/gradle-7.3.3-all.zip

                                      (: Worked :)

Required:

  1. JDK 18+

If you have a low version of JDK downgrade your gradle version. (ex, distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip)


2

Goto this directory :C:\Users\your username.gradle\caches Rename the gradle in question and then go and run 'react-native run-android' again your problem should be resolved!

Agboweroh
  • 36
  • 1
2

For me, the removal of the cache didn't solve the problem.

I opened Android Studio and ran the Gradle build process. It downloaded the correct libraries and then react-native run-android ran flawlessly.

Amit
  • 2,389
  • 22
  • 29
0

In my case I had the newest version of Java (19) and gradle version 6.5. In order know the right version of gradle:

  1. Open terminal and write

java --version

Then open this page:

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

Then open this file:

Your-Project\android\gradle\wrapper\gradle-wrapper.properties

And update this filed

distributionUrl=https://services.gradle.org/distributions/gradle-7.6-all.zip

In my case 7.6 is the version of gradle that supports Java 19

0

I had a similar issue when running my react-native application. this is coming late but it can help someone. The recommended jdk for react native as of writing is jdk-11. I have tried all the steps steps above but same error.

So, I installed jdk-11 and updated my JAVA_HOME and everything works fine.

you can follow the steps here.

https://reactnative.dev/docs/environment-setup?guide=native&platform=android

Festus Fashola
  • 151
  • 2
  • 9