LoginSignup
0
0

More than 1 year has passed since last update.

flutter doctorでAndroid license status unknownになった場合の対処法

Last updated at Posted at 2021-12-02

flutter doctorした時にこのようなエラーが出るケースがある

❯ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale ja-JP)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.60.2)
[✓] Connected device (3 available)

! Doctor found issues in 1 category.

flutter doctor --android-licensesを実行してみる

❯ flutter doctor --android-licenses

ERROR: JAVA_HOME is set to an invalid directory: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

javaを入れてJAVA_HOMEを有効にする

ここで指定するjavaのバージョンは恐らくAndroid SDKのversionと関係しているのかと予想。
/android/app/build.gradleに記載があるので対応するjavaのバージョンが何かを調べてみても良さそうです。

$ brew tap homebrew/cask-versions
$ brew install adoptopenjdk8 --cask
$ echo JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home >> ~/.zshrc
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0