Flutter Doctor:无法确定 Java 版本 - 需要正确的路径(Linux Mint)

问题描述 投票:0回答:1
richard@linux-mint:~$ flutter doctor -v
[✓] Flutter (Channel stable, 3.24.5, on Linux Mint 22 6.8.0-38-generic, locale
    en_US.UTF-8)
    • Flutter version 3.24.5 on channel stable at
      /home/richard/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (2 weeks ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /usr/lib/Android/Sdk
    • Platform android-Baklava, build-tools 35.0.0
    • Java binary at: /usr/lib/jvm/jdk-21.0.5-oracle-x64/bin/javac/bin/java
    ✗ Cannot execute /usr/lib/jvm/jdk-21.0.5-oracle-x64/bin/javac/bin/java to
      determine the version

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] 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 (version 2024.2)
    • Android Studio at /usr/lib/android-studio
    • Flutter plugin version 82.1.3
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /usr/lib/android-studio
    • Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)

[✓] VS Code (version 1.95.3)
    • VS Code at /usr/share/code
    • Flutter extension version 3.100.0

[✓] Connected device (3 available)
    • Pixel 3a XL (mobile) • 9ADAX0LF5K • android-arm64  • Android 12 (API 32)
    • Linux (desktop)      • linux      • linux-x64      • Linux Mint 22
      6.8.0-38-generic
    • Chrome (web)         • chrome     • web-javascript • Google Chrome
      131.0.6778.85

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

如何将路径更改为正确的路径...

/usr/lib/jvm/jdk-21.0.5-oracle-x64/bin

许多解决方案都指向安装 Android Studio(确实如此)并安装 Android SDK 命令行工具(最新)。安装了命令行工具,并且 Android Studio > SDK 工具对话框中的复选框验证了这一点。

我认为 Java 的路径需要修改......出于某种奇怪的原因,它在末尾添加了“/javac/bin/java”。不知道那是从哪里来的!

java linux flutter
1个回答
0
投票

您可以更新路径

  1. 打开终端并运行以下命令来编辑.bashrc文件:

    纳米~/.bashrc

  2. 查找任何错误地将 Java 添加到您的 PATH 的行,并删除任何引用 /javac/bin/java 的行。

    导出 PATH=$PATH:/usr/lib/jvm/jdk-21.0.5-oracle-x64/bin

  3. 保存并重新加载文件

    源~/.bashrc

  4. 再次运行 Flutter doctor 来确认您的环境

    扑医生-v

N/B:如果您安装了 Android Studio,请确保它指向正确的 JDK 。 https://www.geeksforgeeks.org/how-to-set-java-sdk-path-in-android-studio/

© www.soinside.com 2019 - 2024. All rights reserved.