Problem
After upgrading my Android Studio, due I wanted to finish some unfinished Flutter projects of mine, to below version, I ran into an issue after running “Flutter Doctor” in my PowerShell.
Android Studio Giraffe | 2022.3.1 Patch 4
Build #AI-223.8836.35.2231.11090377, built on November 14, 2023
Runtime version: 17.0.6+0-b2043.56-10027231 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry:
external.system.auto.import.disabled=true
ide.text.editor.with.preview.show.floating.toolbar=false
Non-Bundled Plugins:
Dart (223.8977)
io.flutter (76.3.2)
The error I received was following, after I ran the command “flutter doctor —android-licenses”:
Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
PS C:\src\flutter> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
...
...
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
...
...
! Doctor found issues in 5 categories.
PS C:\src\flutter> flutter doctor --android-licenses
Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
NOTE: Please see my other article if you also received "Unable to find bundled Java Version" after running the command "flutter doctor".
Unable to find bundled Java Version
Solution
Managed to fix this by following a solution I found on the public internet domain, credit where credit due, maybe an older problem, but it was the first I found. If you want to read, read further. If you want an image, than I refer you to the source article.| Src: 1
Fix the Android Studio License
- Open Android Studio.
- On the far right side you will see 3 vertical dots, click it and select “SDK Manager”.
- Select the tab “SDK Tools”.
- IMPORTANT: In the bottom right right corner, select “Show package details”.
- You will see a long list, but just close the first 2 chevrons and you will see “Android SDK Command-line Tools (latest)“.
- Select/Choose Android SDK Command-line Tools => version 8.0, no need to un-select version 11.0 (leave as is!).
- Type %LocalAppData% and than goto Android\Sdk\cmdline-tools. If you get lost, the full path is C:\Users\ <USER_NAME> \AppData\Local\Android\Sdk\cmdline-tools
- Remove the directory “latest” to the garbage bin, (maybe renaming it also works?) it as you will need it again later.
- Run the command again “flutter doctor —android-licenses”.
Issue should be fixed and you also received a warning, (possible because in step 6 I did not un-select version 11.0).
A FEW MOMENTS OR DAYS LATER…
I decided to move on with some further steps, so follow along at your own risk, I am not taking any responsibility of your own actions.
Further Steps (own risk)
- Retrieve the directory “latest” from the garbage bin (which was removed in previous step 8).
- Run the command again “flutter doctor —android-licenses”.
You should now get below output:
PS C:\src\flutter> flutter doctor --android-licenses
[=======================================] 100% Computing updates...
All SDK package licenses accepted.
PS C:\src\flutter>
- Go to step 6 again and un-select 8.0, Android Studio will now remove the version.
- Check if an upgrade is available, run: flutter upgrade.
PS C:\src\flutter> flutter upgrade
Upgrading Flutter to 3.16.3 from 3.16.0 in C:\src\flutter...
Checking Dart SDK version...
Downloading Dart SDK from Flutter engine 54a7145303f0dd9d0f93424a2e124eb4abef5091...
Expanding downloaded archive with PowerShell...
Building flutter tool...
Running pub upgrade...
Resolving dependencies...
Got dependencies.
- Run: flutter doctor or flutter doctor -v
PS C:\src\flutter> flutter doctor -v
[√] Flutter (Channel stable, 3.16.3, on Microsoft Windows [Version 10.0.22631.2715], locale nl-NL)
• Flutter version 3.16.3 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b0366e0a3f (5 days ago), 2023-12-05 19:46:39 -0800
• Engine revision 54a7145303
• Dart version 3.2.3
• DevTools version 2.28.4
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at C:\Users\flapp\AppData\Local\Android\sdk
• Platform android-33-ext4, build-tools 33.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.8.34309.116
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2022.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231)
[√] VS Code (version 1.85.0)
• VS Code at C:\Users\flapp\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.78.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.2715]
• Chrome (web) • chrome • web-javascript • Google Chrome 120.0.6099.71
• Edge (web) • edge • web-javascript • Microsoft Edge 120.0.2210.61
[√] Network resources
• All expected network resources are available.
• No issues found!
PS C:\src\flutter>