[Flutter 環境構築] Android toolchainのエラーを解消する方法

Flutter の環境構築を行なっている際、Android　Studio をインストールし、
```flutter doctor```を実行して確認した際にエラーが出てしまう。。。

## 問題のエラー文
```
＄　fflutter doctor -v
[✓] Flutter (Channel master, 2.9.0-1.0.pre.207, on Ubuntu 20.04.3 LTS 5.10.76-linuxkit, locale en_US)
    • Flutter version 2.9.0-1.0.pre.207 at /usr/local/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7addb91364 (10 hours ago), 2021-12-28 04:54:11 -0500
    • Engine revision 01d19ceef4
    • Dart version 2.16.0 (build 2.16.0-134.0.dev)
    • DevTools version 2.9.2

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /usr/local/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

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

[✓] Android Studio
    • Android Studio at /opt/android-studio
    • 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 11.0.10+0-b96-7249189)

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available
```

```
$ 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 SDK Command-line Tools(latest)にチェックを入れる
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/454289/30b81afe-9593-665d-6cfb-bbc7af812a90.png)
これでもダメ、、、



## 解決方法
### ① まずJava８をインストールかつ、適用
```
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /usr/local/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
```
上記にある```Run `path/to/sdkmanager --install "cmdline-tools;latest"```を実行するだけでした！
実行する場所と、パスが間違っててうまくいかなかっただけでしたので、そこだけ気をつけたらうまくいきます！

## 結果
```
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 2.9.0-1.0.pre.207, on Ubuntu 20.04.3 LTS 5.10.76-linuxkit, locale en_US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] Connected device (1 available)
[✓] HTTP Host Availability

• No issues found!
```

### 余談
途中でこれが原因！？と思ったのが、こちらの公式のサイトに書かれてある、Javaのバージョンについて。Java8がないとだめ、とあったのでインストールかつ反映させたのですがかわりなし、、、
![スクリーンショット 2021-12-29 4.57.37.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/454289/c7a88167-f178-57ef-4e01-4dadce6de7ab.png)
スクリーンショット 2021-12-29 4.57.37


## 参考リンク
https://qiita.com/iseruuuuu/items/8bce7046bb260d515038

https://docs.flutter.dev/get-started/install/linux#agree-to-android-licenses

https://www.codewithhussain.com/2021/09/cmdline-tools-component-is-missing-in.html

https://qiita.com/uhooi/items/9a6747084bcfd4df07a6

https://zenn.dev/kikiki_kiki/scraps/b8e10b37dbffd4