React Native "Could not open settings remapped class cache" - react-native

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

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

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!

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.

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:
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)

Related

Gradle version issue in dolphin Andriod studio version

After the updating the new version of Android Studio ,I am facing the error message in our Android Studio.
**> Unsupported Gradle.
> The project uses Gradle version which is incompatible with Android Studio 2021.3.
>
> Possible solution:
> Open Gradle wrapper settings, upgrade version to 3.0 or newer and reload the project
> **
I am try to solve bit it had not solved.
I created new project because I think it is temporary error but after all is has not solved the issue.
I would recommend updating Gradle for your project.
You can execute the follwing commands from the command line (in the root directory of your project), or you can just click on the "terminal" tab at the bottom of Android studio.
First, check your Gradle version:
./gradlew --version
You will get a lot of results, but you only care about the line that says something like this:
------------------------------------------------------------
Gradle 7.4
------------------------------------------------------------
Assuming you are on an earlier version of Gradle, you can update to the latest by using the following command (replacing '7.6' with the version you wish to use):
./gradlew wrapper --gradle-version 7.6
Depending on your project, that should be all you need. If you have incompatabilities with your code and the version of Gradle, Android studio should issue you further guidance.

gradle issues details in discription

Unable to find method 'org.gradle.api.artifacts.result.ComponentSelectionReason.getDescription()Ljava/lang/String;'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I resolved the error by downgrading gradle.
To do so, in the gradle-wrapper.properties file, I made the following changes.
It was:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
It is now:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
If you are using IntelliJ Community Edition, upgrading the IDE to IntelliJ IDEA 2021.1.2 (Community Edition) solved the problem for me. Previously I was using the 2019 version and I was getting the same error.
I had the same problem. I solved it, when I update Android Studio with Gradle.
Upgrading IntelliJ version from 2019 to 2021 fixed the issue for me
org.gradle.internal.exceptions.LocationAwareException:
'java.lang.String
org.gradle.api.tasks.SourceSet.getCompileConfigurationName()'
Caused by: java.lang.NoSuchMethodError: 'java.lang.String
org.gradle.api.tasks.SourceSet.getCompileConfigurationName()'
I got the same error mentioned in the question with the above exceptions.
As mentioned above, upgrading the intellij version from from 2019 to 2021 helped me.
Upgrading Intellij version worked.
Either upgrade or downgrade your IntelliJ idea. Stupid but that's the way to go. I jumped between 2021.3.2, 2019.3.1, 2021.1.2 and some version of 2022 however, downgrading to 2021.1.3 fixed my issue. It all started after I changed my hdd and downloaded the latest version intellij idea.

IntelliJ error - could not open init generic class cache for initialization script

enter image description here
enter image description here
I was trying to download IntelliJ and learn Kotlin, but i get a BUG error before i am starting, and i dont now what to do..
I have try to delete the scipts folder, but it just make a new scipts folder, and say the same error. I have also reinstall IntelliJ, and thats give the same error.
Is der someone there can help me? :-)
Could not open init generic class cache for initialization script 'C:\Users\username\AppData\Local\Temp\wrapper_init4.gradle' (C:\Users\username.gradle\caches\6.6.1\scripts\3yb5naxddghzghazzdf2vk0em).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 60
As per the details in your error message, you can see that the root cause is a gradle error.
Gradle is likely using an unsupported version of the JVM in your case (e.g. I could reproduce the error in the latest IntelliJ 2021.3 version where gradle was using JVM 17 from my home path, while the IDE itself was using JDK 11.) In the attached IntelliJ Preferences screen, note that the JVM used by Gradle is specified separately.
To fix the error, verify the JVM version being used by gradle and specify a JVM 11 version to gradle.
IntelliJ Gradle Preferences Screenshot:
You should set these options when you create your project enter image description here
Or, when creating a project, choose Java - Kotlin\JVM
For me this problem occurred when i was using wrong JDK file to build the project that is the Gradle JDK used was a normal SE JDK rather than one preferred by Android Studio so you follow the following steps to solve it.
Go to Settings (ctrl + alt + s)
Go to Build,Execution and Deployment
Then select Build Tools > Gradle
Change Gradle JDK to jbr-17 (the one i am using) you can prefer to choose options from Android studio Java Home or Default JDK

How can I upgrade react-native gradle version

I need help.
I can't upgrade gradle version of my react-native project.
I try a lot of things, downloaded last version of Android Studio & SDK Tools etc.
I changed this file \android\gradle\wrapper\gradle-wrapper.properties, I tried to upgrade using npm install -g react-native-git-upgrade but still I can't upgrade it.
When I react-native eject It's exports
"distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip"
Waiting for answers.
In android/build.gradle you have to edit this line
classpath 'com.android.tools.build:gradle:x.y.z'
Change x.y.z with the version you want. Edit it with Android Studio then click Sync now
In {yourProject}\android\gradle\wrapper\gradle-wrapper.properties, update:
distributionUrl=https\://services.gradle.org/distributions/gradle-{your version}.zip
Find your version of gradle with
gradle --version
You may need to install gradle wrapper if you haven't already.
you can go to https://services.gradle.org/distributions/ and check that latest -all.zip version of gradle and update the same in your gradle-wrapper.properties file. When you run your react-native app the next time, your gradle will first get upgraded and then run.
There are two things
Android Gradle Plugin
You can see the version of it in android/build.gradle file and update it using Daniel's answer here
Gradle version
You can see this in android\gradle\wrapper\gradle-wrapper.properties file and update it using the answer mentioned here
To know the difference between them refer following links:
https://developer.android.com/studio/releases/gradle-plugin
difference between android gradle plugin and gradle
Open Android Studio and navigate to File → Project Structure
Then click on the Project option.
then choose the latest version of Gradle. After that click on Ok.
From Gradle's site:
https://gradle.org/install/#with-the-gradle-wrapper
Upgrade with the Gradle Wrapper If your existing Gradle-based build
uses the Gradle Wrapper, you can easily upgrade by running the wrapper
task, specifying the desired Gradle version:
$ ./gradlew wrapper --gradle-version=6.6.1 --distribution-type=bin
Note that it is not necessary for Gradle to be installed to use the
Gradle wrapper. The next invocation of gradlew or gradlew.bat will
download and cache the specified version of Gradle.
$ ./gradlew tasks
Downloading https://services.gradle.org/distributions/gradle-6.6.1-bin.zip ...
Run these commands in your project's android folder
I had opened my project in Terminal and ran open -a /Applications/Android\ Studio.app to open Android Studio but so that it can access node to download my gradle version which it did automatically.
Learned from this original post: React Native on Android: Cannot run program "node": error=2, No such file or directory
For react native
Go to File -> Project Structure -> Change gradle version to 6.1.1 plugin version to 4.0.0
Try different combinations
Use this link - https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle

Gradle settings error

Error:The project is using an unsupported version of Gradle. Please use version 1.10.
Please point to a supported Gradle version in the project's Gradle settings or in the project's Gradle wrapper (if applicable.)
Gradle settings
how to resolve above qouery ?
Duplicate of a question raised at Gradle forum - http://forums.gradle.org/gradle/topics/gradle_settings_error
It is not a query but an error statement and it tells you what to do.