Anat's
Anat's

Reputation: 411

Flutter build error for the first time :Could not open settings remapped class cache for 7yvt6la2007dno98lt3rzbguf

I just downloaded Flutter and tried to learn the emulator with the first default code which Google offered. But it does not run at all!

I have the dart and flutter plugins installed. I also changed the order of jcenter() and google() too

like this:

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        jcenter()
        google()
    }

   
dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        google()

    }
}

And the error is:

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings remapped class cache for 7yvt6la2007dno98lt3rzbguf (/Users/[myname]/.gradle/caches/5.6.2/scripts-remapped/settings_7iv4l88jiyzeatj2wku74hwcv/7yvt6la2007dno98lt3rzbguf/settings8410a2d21ed2f87c8a0398566330ee52).
> Could not open settings generic class cache for settings file '/Users/[myname]/AndroidStudioProjects/test_app/android/settings.gradle' (/Users/[myname]/.gradle/caches/5.6.2/scripts/7yvt6la2007dno98lt3rzbguf/settings/settings8410a2d21ed2f87c8a0398566330ee52).
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 57

* 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 568ms
Finished with error: Gradle task assembleDebug failed with exit code 1

Upvotes: 30

Views: 66790

Answers (16)

Ya Yura
Ya Yura

Reputation: 621

I've just built in newly installed VS code and everything worked, did not ask anything, there were no errors. magic!

Upvotes: 0

Shervin
Shervin

Reputation: 11

Separately, I opened android module in Android Studio, then gradle started to build, then I opened the Flutter project again. it is ok

Upvotes: 0

Working solution 2023

I faced the exact same issue.... Spent couple of hours figuring it out! Here are things I did to get the thing working

  1. Delete .gradle folder. In my case, I'm on MacOs... So I executed sudo rm -r ~./gradle
  2. Upgrade your Java version
  3. Execute ./gradlew clean in the android directory of your project
  4. Run pub flutter clean then flutter pub get
  5. Launch the build, and it should be fine ✨

Upvotes: 3

Gk Mohammad Emon
Gk Mohammad Emon

Reputation: 6936

For my case , I'm using M1 chipped Mac OS. First upgrade your gradle distribution -

distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

in gradle-wrapper.properties.

Then you might face an issue like that -

accessible: module java.base does not "opens java.io" to unnamed module @42760a00

if you face this please add a like in gradle.property.

org.gradle.jvmargs=-Xmx1536M --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED

enter image description here

Ref 1 and Ref 2

Upvotes: 1

sahad
sahad

Reputation: 31

Please update gradle version

distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip

in gradle-wrapper.properties

Upvotes: 1

Anshu Meena
Anshu Meena

Reputation: 381

i have the same issue i have java 17 installed in my system

after searching this on internet i found that if you downgrade your java from whatever to java 8 or java 11 then it's going to work.

i downgrade to java 11 and its works

Upvotes: 0

Rajitha Udayanga
Rajitha Udayanga

Reputation: 1732

Delete the .gradle file and then run ./gradlew clean

Upvotes: 2

Sterlingking
Sterlingking

Reputation: 200

In other, for me to solve this issue,

  1. I had to open my project in finder and then
  2. Dragged the android folder onto Android Studio. It will start from afresh to resync my project with all neccessary conflicting gradle versions and jdk's .

Note while the syncing was going on, I made sure to accept every upgrade recommendation brought up on the dialog until the process was completed.

When this was done, I went back to my project, ran it again and it worked smoothly.

Open project in finder

Drag android folder into android studio to begin resync

Upvotes: 4

Aron
Aron

Reputation: 3571

Since Android Studio comes bundled with JDK, it may be a solution to downgrade (or upgrade?) your Android Studio version.

For example, if you are still using Flutter 1.x, I recommend using Android Studio up to 4.2.x. This requires no additional installations or configuration changes, whereas later versions cause all sorts of weird issues.

Upvotes: 0

Lugo
Lugo

Reputation: 21

Try to uninstall java, restart android studio and run the application again. Grandle handled everything by itself.

Upvotes: 0

Cyrax
Cyrax

Reputation: 827

You need to update version of Gradle:

  1. go to https://gradle.org/install/ and get info about last version (for now it is 7.1.1)
  2. open gradle/wrapper/gradle-wrapper.properties and change version to last

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

Upvotes: 16

Baracus
Baracus

Reputation: 630

If you are in Windows 10, set the JAVA_HOME environment variable to the JRE for Android Studio. For example:

C:\Program Files\Android\Android Studio\jre

Upvotes: 12

Bohdan Skochko
Bohdan Skochko

Reputation: 161

I had the same issue: For fixing install openJdk8 version https://adoptopenjdk.net/upstream.html?variant=openjdk11&jvmVariant=openjdk8 Also, change the path to OpenJDK place

Upvotes: 1

MendelG
MendelG

Reputation: 20048

I had the same issue with a slightly different error message:

... Could not open settings remapped class cache for 3n8ygcxrc7nelqcw5tzib8bo6....


I was able to resolve this issue by opening the android folder in my project with Android Studio and syncing Gradle. Here's how:

Let's say that my current Flutter project is in the directory C:\Users\Mendel\Documents\Flutter Projects\test. In this directory, there's an android folder, open this android folder in Android Studio instead of your current Flutter project, (goto File -> Open) and let Gradle Sync run (it will run automatically, the process will take some time). Once done, re-open your Flutter project.

Upvotes: 7

Chamindu
Chamindu

Reputation: 391

I don't know reason for this error. But I was updated gradle version to the latest in gradle-wrapper.properties file. Then sync. It worked for me.

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

Upvotes: 4

Anat's
Anat's

Reputation: 411

I got it! My current java version was 12 and I downgraded it to Java 8. Then everything works fine.

I'll leave it, hoping it can help somebody struggling in the future will

Upvotes: 8

Related Questions