備忘録: M2 MacBook Air (arm64) に Flutter を入れる

## まえがき 単に自分用に情報をまとめたかった。備忘録です。 ## Flutter をインストール 今回は asdf でインストールします。 ```console $ # asdf で Flutter プラグインをインストール $ asdf plugin add flutter $ # インストール可能なバージョンを列挙 $ asdf list all flutter $ # 最新の安定版をインストール $ asdf install flutter latest $ # インストールされた Flutter を確認 $ flutter --version Flutter 3.0.5 • channel stable • https://github.com/flutter/flutter.git Framework • revision f1875d570e (4 weeks ago) • 2022-07-13 11:24:16 -0700 Engine • revision e85ea0e79c Tools • Dart 2.17.6 • DevTools 2.12.2 ``` この時点で `flutter doctor --android-licenses` すると以下みたいなこと言われる気がするので Android Studio をインストールします。 ```console $ flutter doctor --android-licenses Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this. ``` (もうちょっと別のエラー文言だった気がするけどログを失ってしまいました) ## Android Studio のインストール 今回は JetBrains Toolbox 経由でインストールします。 ```console $ # JetBrains Toolbox をインストール $ brew install --cask jetbrains-toolbox ``` JetBrains Toolbox を起動し、 Android Studio をインストールします。 (画像割愛) Android Studio を起動し、 `More Actions` から `SDK Manager` を選択します。 ![20220807-01-001.png](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6hmCN1lXxFi0zLbu7EotVSoHZS1WVif08ZO2sP0HmSLqMnZfROZDX38fK3acyzz3MRZWnQxDwHxi49tYbMpC1z4CoqHC_hdu0lJe2i-g3RgLf6NjU4KxeYac8KKOT5bTtCtpWsG2zpJyq2Wh56Bxb7Vfzl7qqeenqjz71MXFORPd2OT1Jxc0kFts3/s1600/20220807-01-001.png) `SDK Tools` のタブから `Android SDK Command-line Tools` にチェックを入れ `Apply` を押してインストールを実行します。 ![20220807-01-002.png](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1EcjuTVuIlDo7AbBJfvfe70lW0DL1oCBzSEhqKaBjKW6xhBIkSB-RuV8TGE9t_EWr6n6l6zTBpgzuxNdqxWk_KFjyMsiOHvEZ9UJr17YB-MzuqA46ys1njm8tVMOEIaZxQnwtdUPvfxDYyWLfV6M3F8FGRRUOi5w49bi4AQh3ObFnhk8OEb1NBX86/s2188/20220807-01-002.png) Android SDK Command-line Tools のインストールが終わったら、以下を実行して、諸々のライセンスに同意します。 ```console $ flutter doctor --android-licenses ...略... Accept? (y/N): y All SDK package licenses accepted ``` この時点での `flutter doctor` は以下。 ```console $ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F2081 darwin-arm, locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [!] Xcode - develop for iOS and macOS ✗ Xcode installation is incomplete; a full installation is necessary for iOS development. Download at: https://developer.apple.com/xcode/download/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.69.2) [✓] Connected device (2 available) [✓] HTTP Host Availability ! Doctor found issues in 1 category. ``` Xcode を入れてなかった。 ## Xcode のインストール `flutter doctor` に従って Xcode をインストールします。 今回は Xcodes 経由でインストールします。 ``` $ # Xcodes のインストール $ brew install --cask xcodes ``` Xcodes.app の `Preference` を開き、 `Active/Selected` の項目 `[x] Automatically create symbolic link to Xcode.app` を有効にします。 ![20220807-01-003.png](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF3XMeIpEMLT1J481d8HNI70xkcebQ4KGID0bvBV7by7EyNAyaH-oj78waCt2y4TDVn2uL4mgc1mibe50V9nfQf-RQKPABKDgFfhi0gCCG8CmjFF3x3L0Hvo40nOt3q93mZi4saNwulQdc61digiJzPG08xlVbgsBYgqcXeqIyxVpiGOkd39DfstIk/s1528/20220807-01-003.png) Xcodes から 最新の安定版の Xcode をインストールし、チェックマークを ON にし `Active/Selected` 状態にします。 ![20220807-01-004.png](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjalEceYU3LiBQcbCi-vC3QNNdWfpaMsJl9AmVaoJxNL5SO-LWMsnYRSQeC6-5tJG1Ja53JwowQFcPnOas-xk56ERPaX6O2nggk9U7U_t-LSUgxy18VZxDnEkKOIzUjQBAUfL0OV_ykF7czSHwcEvURQDrwbsV-6GzlrOGXFGe4r4AcFaTfIn6oCDSa/s2024/20220807-01-004.png) `flutter doctor` に従って以下を実行します。 ```console $ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer $ sudo xcodebuild -runFirstLaunch ``` この時点での `flutter doctor` は以下。 ```console $ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F2081 darwin-arm, locale ja-JP) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.69.2) [✓] Connected device (2 available) [✓] HTTP Host Availability • No issues found! ``` OK! ## あとがき 昔インストールしたときはめっちゃハマった気がするけど、今回は一切ハマらなかった…なんでだろう。 まぁ、うまくいったからヨシ!👉
このエントリーをはてなブックマークに追加

このブログの人気の投稿

OpenTelemetry 互換の Observability 基盤比較検討

AWS アカウントを作成したらまず実行するスクリプト

Hello, World!