错误:加载主类com.android.sdklib.tool.sdkmanager.SdkManagerCli时发生LinkageError

Bha*_*ana 21 java linux ubuntu flutter

我正在尝试在 Ubuntu 中使用 VS Code 设置 flutter。我已按照安装指南进行操作,并按照 flutter doctor 的要求安装了最新的 cmdline 工具。

\n

现在这是我再次运行 flutter doctor 时得到的输出

\n
    \xe2\x9c\x97 Android license status unknown.\n      Run `flutter doctor --android-licenses` to accept the SDK licenses.\n      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details. \n
Run Code Online (Sandbox Code Playgroud)\n

运行时flutter doctor --android-licenses出现以下错误

\n
java.lang.UnsupportedClassVersionError: \ncom/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled \nby a more recent version of the Java Runtime (class file version 61.0), \nthis version of the Java Runtime only recognizes class file versions up to 55.0\n
Run Code Online (Sandbox Code Playgroud)\n

sudo apt install openjdk-17-jdk我尝试使用并设置环境变量升级到 Java 17 ,但问题仍然存在。

\n

小智 42

I was able to resolve this issue on Windows 10 with these steps

安装Android SDK命令行工具8.0

  1. Using the Android Studio SDK manager, install Android SDK Command-line Tools 8.0. You may need to toggle the checkboxes highlighted in green to see the older versions like 8.0.
  2. Using windows explorer, navigate to the Sdk/cmdline-tools folder. On my system it's located at C:\Users\<USER_NAME>\AppData\Local\Android\Sdk\cmdline-tools.
  3. Rename the 8.0 folder to latest
  4. Run flutter doctor --android-licenses.


小智 16

试试这个(适用于 Mac)...

  • 查看Android SDK命令行工具(最新)
  • 检查Android SDK命令行工具8.0
  • 单击“应用”
  • 在 Mac 中,转到文件夹/Users/Library/Android/sdk/cmdline-tools并将其重命名8.0latest.
  • 再次运行 Flutter doctor。


小智 0

我遇到了完全相同的问题,但是是在 Windows 上。我通过完全卸载JDK解决了这个问题,在网上搜索结果发现可能是这个问题,然后安装最新版本(20)。