22

I tried to figure it out, but I couldn't even find how. Please help me.

When I try to run my first flutter app this happen:

FAILURE: Build failed with an exception.

* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android\settings.gradle' (C:\Users\Angel\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60

* 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 2s
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                         3.5s
Exception: Gradle task assembleDebug failed with exit code 1

I already tried with a physical device and the emulator. I try with "flutter clean". flutter doctor -v say all is good.

If it's helpful here is what comes out when running 'flutter run -v':

[ +119 ms] executing: [C:\src\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +128 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 4d7946a68d26794349189cf21b3f68cc6fe61dcb
[   +2 ms] executing: [C:\src\flutter/] git tag --points-at 4d7946a68d26794349189cf21b3f68cc6fe61dcb
[ +107 ms] Exit code 0 from: git tag --points-at 4d7946a68d26794349189cf21b3f68cc6fe61dcb
[        ] 2.0.3
[  +85 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +77 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[   +1 ms] executing: [C:\src\flutter/] git ls-remote --get-url origin
[  +79 ms] Exit code 0 from: git ls-remote --get-url origin
[   +2 ms] https://github.com/flutter/flutter.git
[ +129 ms] executing: [C:\src\flutter/] git rev-parse --abbrev-ref HEAD
[  +78 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[ +188 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +124 ms] executing: C:\Users\Angel\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[  +82 ms] List of devices attached
           R9HN50CEZ7J            device product:a11qub model:SM_A115M device:a11q transport_id:4
[  +10 ms] C:\Users\Angel\AppData\Local\Android\sdk\platform-tools\adb.exe -s R9HN50CEZ7J shell getprop
[ +291 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[  +14 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +217 ms] Skipping pub get: version match.
[ +268 ms] Generating
C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java  
[ +129 ms] ro.hardware = qcom
[  +88 ms] Initializing file store
[  +22 ms] Skipping target: gen_localizations
[  +18 ms] complete
[  +20 ms] Launching lib\main.dart on SM A115M in debug mode...
[  +15 ms] C:\src\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev
C:\src\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\src\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names   
--experimental-emit-debug-metadata --output-dill
C:\Users\Angel\AppData\Local\Temp\flutter_tools.b8ee7616\flutter_tool.23a43e65\app.dill --packages
C:\Users\Angel\Downloads\Codigo\Flutter\first_app\.dart_tool\package_config.json -Ddart.vm.profile=false
-Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill  
build\cache.dill.track.dill
[  +51 ms] executing: C:\Users\Angel\AppData\Local\Android\sdk\platform-tools\adb.exe -s R9HN50CEZ7J shell -x logcat -v time -t1
[  +42 ms] <- compile package:first_app/main.dart
[ +216 ms] --------- beginning of main
                    03-31 11:34:37.956 W/fb4a.ReqContexts(10384): continueFromDirect() replaced by create()
[  +21 ms] executing: C:\Users\Angel\AppData\Local\Android\sdk\platform-tools\adb.exe version
[ +154 ms] Android Debug Bridge version 1.0.41
                    Version 31.0.1-7187441
                    Installed as C:\Users\Angel\AppData\Local\Android\sdk\platform-tools\adb.exe
[  +53 ms] executing: C:\Users\Angel\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[ +135 ms] Building APK
[  +56 ms] Running Gradle task 'assembleDebug'...
[  +15 ms] Using gradle from C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android\gradlew.bat.
[  +40 ms] C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android\gradlew.bat mode: 33279 rwxrwxrwx.
[  +25 ms] executing: [C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android/]
C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android\gradlew.bat -Pverbose=true -Ptarget-platform=android-arm
-Ptarget=C:\Users\Angel\Downloads\Codigo\Flutter\first_app\lib\main.dart -Ptrack-widget-creation=true
-Pfilesystem-scheme=org-dartlang-root assembleDebug
[+2941 ms] FAILURE: Build failed with an exception.
[ +137 ms] * What went wrong:
[  +14 ms] Could not open settings generic class cache for settings file
'C:\Users\Angel\Downloads\Codigo\Flutter\first_app\android\settings.gradle'
(C:\Users\Angel\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
[  +11 ms] > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60[  +25 ms] * Try:
[   +2 ms] 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.
[  +19 ms] * Get more help at https://help.gradle.org
[   +4 ms] BUILD FAILED in 2s
[ +362 ms] Running Gradle task 'assembleDebug'... (completed in 3.6s)
[+11837 ms] Exception: Gradle task assembleDebug failed with exit code 1
[   +3 ms] "flutter run" took 17,569ms.
[   +8 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:644:9)
           <asynchronous suspension>
           #2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1157:12)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1009:27)      
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:197:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure>
           (package:flutter_tools/src/runner/flutter_command_runner.dart:278:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #9      AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
           <asynchronous suspension>
           #10     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:234:5)        
           <asynchronous suspension>
           #11     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:64:9)
           <asynchronous suspension>
           #12     run.<anonymous closure> (package:flutter_tools/runner.dart:62:12)
           <asynchronous suspension>
           #13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #14     AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
           <asynchronous suspension>
           #15     runInContext (package:flutter_tools/src/context_runner.dart:73:10)
           <asynchronous suspension>
           #16     main (package:flutter_tools/executable.dart:90:3)
           <asynchronous suspension>


[ +175 ms] ensureAnalyticsSent: 163ms
[   +2 ms] Running shutdown hooks
[   +1 ms] Shutdown hook priority 4
[+3035 ms] Shutdown hooks complete
[   +4 ms] exiting with code 1

Please, I really need help.

3
  • 1
    This seems similar to the issue from this thread stackoverflow.com/questions/32900912/… Commented Mar 31, 2021 at 18:52
  • "Unsupported class file major version" is the sort of error that a java runtime gives when the classfile was compiled by a newer version of java. If the suggestions from Razvan S' linked question don't work, try making sure all of the java installs on your machine are the latest version (there could be several in different SDKs and IDEs) Commented Mar 31, 2021 at 19:02
  • 1
    I solve it! I only change my JDK version of 16 to 11 and now work good! Commented Apr 6, 2021 at 0:58

11 Answers 11

16

I have a problem to than i saw your comment. My JDK version of 16 downgraded to 11 and its worked.

Sign up to request clarification or add additional context in comments.

3 Comments

You are life saver, I was trying my first flutter app to make it running. And was only able to do after downgrading from 16 to 11.
This happened to me after an upgrade of Android Studio and I had to follow these steps to fix it stackoverflow.com/questions/51281702/…
Some packages may require newer versions of jdk, downgrading is a temporary solution
3

I had the same issue..

run flutter doctor and make sure you have android studio installed that worked for me.

Comments

3

I just update distributionUrl value at android\gradle\wrapper\gradle-wrapper.properties to a gradle compatible with my JDK version (19)

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

So, I use gradle 7.6 following the Compatibility Matrix from Gradle docs (https://docs.gradle.org/8.0/userguide/compatibility.html)

Comments

2

change

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

to

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

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
1

I resolved this issue by downgrading my JDK version 19 to JDK 17. Also, change the paths of both - User Variables and System Variables.

And Don't forget to configure the Project Structure of the Flutter Project after JDK Downgrade. Screenshot for Reference

Comments

1

I have changed the gradle version of java, its work for me.

  1. first check the gardle java version => through commond : java -version or => Go to C drive -> program files -> java (where you see the jdk file and version)

  2. Second check 'Edit and System Enviroment' => check the path and also check the JAVA HOME path

  3. Third Go to your project Android -> app -> gradle/wrapper -> gradle-warpper.properties change the gradle version

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

check with this link https://docs.gradle.org/current/userguide/compatibility.html

Comments

1

Dec 2024 answer

Current JDK version : 17

In project/android/gradle/wrapper/gradle-wrapper.properties, set this

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

There are many answers here which tell you to check compatibility matrix but in this context I think instead of checking with java - gradle compatibility, you need to check for Android - Gradle compatibility.

on Java 17, my 7.3 Gradle was not supported and error was shown by Android studio. I scrolled down to bottom of https://docs.gradle.org/current/userguide/compatibility.html#Android to check for Android - gradle

Hence, picked 8.3 gradle version.

Comments

0

I have a also face this problem but instead of downgrade JDK version just update distributionUrl and build tools version it work for me

1 Comment

it's works for me. But i had to use gradle version compatible with my JDK version
0

Yes, downgrading the jdk version solves the problem. In may case this problem was experienced both in android studio android project and in IntelJ in spring boot project.

Comments

0

I have fixed the issue by steps below,

  1. Check Gradle version by running command - flutter doctor --verbose. In my case it was - Java version OpenJDK Runtime Environment (build 21.0.3+-79915915-b509.11)
  2. Update Gradle Wrapper: Updated my gradle-wrapper.properties file located in the android/gradle/wrapper directory. Refer the Gradle compatibility documentation - https://docs.gradle.org/current/userguide/compatibility.html. In my case it was 8.5
  3. Set Correct Distribution URL: I updated the distributionUrl in the gradle-wrapper.properties file to the following: distributionUrl=https://services.gradle.org/distributions/gradle-8.5-all.zip

Comments

-1

voici ce que me donne flutter doctor "

PS C:\src\appl2> flutter doctor 
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.27.3, on Microsoft Windows [version 10.0.19045.5608], locale
    fr-FR)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4)
[!] Android Studio (not installed)
[√] VS Code (version 1.98.2)
[√] Connected device (4 available)
[√] Network resources

! Doctor found issues in 1 category."

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.