flutter在macos

问题描述 投票:0回答:1

对于工作,我需要从一个扑通版本切换到另一个颤抖版本,也需要切换到Java。使用git克隆,稳定的通道安装扑通,在一个〜/开发/颤音文件夹上安装。 Java安装了两次,使用Brew和OpenJDK@11 +OpenJDK@17.

所有效果很好

现在,我正在开始一个新项目

flutter doctor -v [✓] Flutter (Channel stable, 3.27.3, on macOS 15.2 24C101 darwin-arm64, locale it-IT) • Flutter version 3.27.3 on channel stable at /Users/mirkotebaldi/development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision c519ee916e (5 giorni fa), 2025-01-21 10:32:23 -0800 • Engine revision e672b006cb • Dart version 3.6.1 • DevTools version 2.40.2 [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) • Android SDK at /Users/mirkotebaldi/Library/Android/sdk • Platform android-35, build-tools 35.0.1 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 16.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16C5032a • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.2) • Android Studio at /Applications/Android Studio.app/Contents • 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 21.0.4+-12422083-b607.1) [✓] VS Code (version 1.96.4) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.102.0 [✓] Connected device (4 available) • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 15 (API 35) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 15.2 24C101 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.2 24C101 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 131.0.6778.265 [✓] Network resources • All expected network resources are available. • No issues found!

我有最新的颤音和最新的Android Studio。如您所见,此Android Studio版本正在使用Java V21,但是我的环境已配置为使用Java17.

echo $JAVA_HOME /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home java --version openjdk 17.0.12 2024-07-16 OpenJDK Runtime Environment Homebrew (build 17.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.12+0, mixed mode, sharing)

当我创建一个新应用时,我会看到此警告

被检测到的Java的配置版本可能与您的新Flutter App中的Gradle版本冲突。

建议我设置

flutter config --jdk-dir=
。我想避免它,因为从Java 11到Java 17的每个切换,我都必须执行很多命令。

我问您是否有一个原因,为什么使用Android Studio the flutter使用Java_home找到Java?如果有一个命令告诉flutter始终使用java_home?

    

我实际上解决了我的~/.zshrc

添加以下行
java android flutter macos
1个回答
1
投票

当我需要从 /要切换到OpenJDK@11 / OpenJDK@17 IRun

brew unlink openjdk@11
brew link openjdk@17
source ~/.zshrc

以这种方式,扑动始终是同步的,我执行的命令比手动执行的命令要少。
    

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.