我正在学习 Flutter,自从我上次接触该项目以来已经过去了几周,现在我又开始继续学习。出于习惯,我在 Ubuntu (24.04) 上安装了更新,但现在由于某种原因,java bin 无法运行...
我正在学习 Flutter,自从我上次接触该项目几周后,我决定继续学习。出于习惯,我在 Ubuntu (24.04) 上安装了更新,现在由于某种原因,java bin 无法运行。此外,当我尝试在不调试的情况下运行时,JAVA_HOME 未被读取。
另外由于某种原因,该 flutter doctor -v
命令并不彻底,因为我确实安装了 Android Studio 以及 Chrome。
注意:尝试在主机 (Linux) 设备上进行调试时,它至少会尝试启动一个窗口并完成这一步。对我来说,这几乎意味着 Android 设备模拟器没有访问 JAVA_HOME 路径。
[user]@workstation:~$ echo $JAVA_HOME
/usr/lib/jvm/java-1.21.0-openjdk-amd64
~/Projects/namer_app$ flutter doctor -v
[] Flutter (Channel stable, 3.22.3, on Freedesktop SDK 23.08 (Flatpak runtime) 6.8.0-41-generic, locale en_US.UTF-8)
• Flutter version 3.22.3 on channel stable at /home/[user]/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b0850beeb2 (7 weeks ago), 2024-07-16 21:43:41 -0700
• Engine revision 235db911ba
• Dart version 3.4.4
• DevTools version 2.34.3
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /home/[user]/Android/Sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_SDK_ROOT = /home/[user]/Android/Sdk
• Java binary at: /usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java
Cannot execute /usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java to determine the version
[] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
[] Connected device (1 available)
• Linux (desktop) • linux • linux-x64 • Freedesktop SDK 23.08 (Flatpak runtime) 6.8.0-41-generic
[] Network resources
• All expected network resources are available.
! Doctor found issues in 3 categories.
Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-1.21.0-openjdk-amd64
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Error: Gradle task assembleDebug failed with exit code 1
Exited (1).