React NativeでAndroidで起動するまでに起きたエラー

## 前提
[Setting up the development environment](https://reactnative.dev/docs/environment-setup)でこのコマンドを実行した直後。

```sh
$ npx react-native init AwesomeProject
```

続くエラーに対応した。
1. [JDKのversionが古い](#1-jdkのversionが古い)
2. [build時に `gradle` のエラー](#2-build時に-gradle-のエラー)
3. [NDKのバージョンが適合しない](#3-ndkのバージョンが適合しない)

## 1. JDKのversionが古い
```sh
$ npx @react-native-community/cli doctor
Common
 ✓ Node.js
 ✓ yarn
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✖ JDK
   - Version found: 1.8.0_281
   - Version supported: >= 8
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ CocoaPods - Required for installing iOS dependencies
 ✓ ios-deploy - Required for installing your app on a physical device with the CLI

Errors:   1
Warnings: 0
```

```sh
$ java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
```

> make sure it is JDK 8 or newer

紛らわしいが、バージョン `x` なら `1.x.0` のように表記される。
8以上だから8でOKだと思ったが、NGの場合もあるらしい。

### 対応
JDKをアップデート
cf. [HomeBrew で AdoptOpenJDK をインストールしてみた（訂正版） - Qiita](https://qiita.com/gishi_yama/items/9cdb3d95ee7f25b8018f#1-cask%E3%81%A7%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E6%96%B9%E6%B3%95)

```sh
$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk
$ java -version
openjdk version "15.0.2" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.2+7, mixed mode, sharing)
```

```sh
$ npx @react-native-community/cli doctor
Common
 ✓ Node.js
 ✓ yarn
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ JDK
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ CocoaPods - Required for installing iOS dependencies
 ✓ ios-deploy - Required for installing your app on a physical device with the CLI

Errors:   0
Warnings: 0
```

## 2. build時に `gradle` のエラー

```sh
$ npx react-native run-android

...

* What went wrong:
Could not initialize class org.codehaus.groovy.reflection.ReflectionCache

...
```

### 対応
Gradleをバージョンアップ: `gradle-6.5-all.zip` に設定した
cf. [JDK 14 support · Issue #10248 · gradle/gradle](https://github.com/gradle/gradle/issues/10248#issuecomment-694064891)
cf. [開発メモ その198 Could not initialize class org.codehaus.groovy.reflection.ReflectionCache · A certain engineer "COMPLEX"](https://taktak.jp/2020/04/02/4275/)

## 3. NDKのバージョンが適合しない
```sh
$ npx react-native run-android

...

> Task :app:compileDebugJavaWithJavac

> Task :app:stripDebugDebugSymbols FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
23 actionable tasks: 23 executed
Note: /Users/shuheikatori/dev/AwesomeProject/android/app/src/debug/java/com/awesomeproject/ReactNativeFlipper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi

...
```

### 対応
NDKのバージョンを `20.1.xxxxx` に変更
よくわからないバージョンの不適合とかキツい。
cf. [[tool]  No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi · Issue #76393 · flutter/flutter](https://github.com/flutter/flutter/issues/76393#issuecomment-788686721)

## 🎉
```sh
$ npx react-native run-android

...

BUILD SUCCESSFUL in 12s
27 actionable tasks: 5 executed, 22 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.awesomeproject/.MainActivity }
```