Flutter環境構築で困ったところ
エラーが発生した
code:flutter doctor
~/AndroidStudioProjects/flutter_app $flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
✓ Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale ja-JP) ! Android toolchain - develop for Android devices (Android SDK version 29.0.0) ✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
✓ iOS toolchain - develop for iOS devices (Xcode 10.2.1) ✓ Android Studio (version 3.4) ✓ IntelliJ IDEA Ultimate Edition (version 2019.1.3) ! No devices available
! Doctor found issues in 2 categories.
code:error部分
Try re-installing or updating your Android SDK Manager.
! Android toolchain - develop for Android devices (Android SDK version 29.0.0) ✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
ライセンスのエラーが出るため以下を実行
code:license
# androidのライセンスエラー
$ sdkmanager --licenses
$ flutter doctor --android-licenses
y連打できれば成功
↓失敗した場合
# sdkmanagerを起動するための.bash_profile(一度ライセンスができたらコメントアウトする)
export SDKMANAGER_OPTS="--add-modules java.se.ee"
# sdkmanagerのコマンドが実行できるようになる
sdkmanager —list
Java12を入れたがエラーが発生
Javaのバージョンが8までしか対応してないため、まだエラーが発生する
code:Javaを削除する
~ $/usr/libexec/java_home -V
Matching Java Virtual Machines (3):
12.0.1, x86_64: "Java SE 12.0.1" /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
12.0.1, x86_64: "OpenJDK 12.0.1" /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home
1.8.0_212, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
~ $sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk
Password:
~ $/usr/libexec/java_home -V
Matching Java Virtual Machines (2):
12.0.1, x86_64: "OpenJDK 12.0.1" /Library/Java/JavaVirtualMachines/openjdk-12.0.1.jdk/Contents/Home
1.8.0_212, x86_64: "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Java8のインストール
homebrewを使ってインストールする
Javaのバージョン8を入れるにはtapが必要らしい
code:java8 install
brew tap AdoptOpenJDK/openjdk
# Java8を入れる
brew cask install adoptopenjdk8
# Bash_profileに追加
export JAVA_HOME=/usr/libexec/java_home -v XX
最終的に設定したもの
code:.bash_profile
export PATH=/Users/ryota/flutter/bin:$PATH
export JAVA_HOME=/usr/libexec/java_home -v "1.8"
PATH=${JAVA_HOME}/bin:${PATH}
# export SDKMANAGER_OPTS="--add-modules java.se.ee"
export ANDROID_HOME=“/usr/local/share/android-sdk”
export PATH=$HOME/Library/Android/sdk/platform-tools:$PATH
export PATH=$HOME/Library/Android/sdk/tools:$PATH
code:javaのバージョン
~ $java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)
code:Flutterバージョン
~ $flutter --version
Framework • revision 7a4c33425d (9 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
code:flutter doctor
~ $flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
✓ Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.14.5 18F132, locale ja-JP) ✓ Android toolchain - develop for Android devices (Android SDK version 29.0.0) ✓ iOS toolchain - develop for iOS devices (Xcode 10.2.1) ✓ Android Studio (version 3.4) ✓ IntelliJ IDEA Ultimate Edition (version 2019.1.3) ✓ Connected device (1 available) • No issues found!