React Nativeでandroidエミュレータを起動できない

# 事象

```
$ react-native run-android                                                                                                                                                            (hello_world) 15:06:50
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Downloading https://services.gradle.org/distributions/gradle-4.4-all.zip
..............................................................................................
Unzipping /Users/hondy12345/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4-all.zip to /Users/hondy12345/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1
Set executable permissions for: /Users/hondy12345/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4/bin/gradle

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '11'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
```

# 原因

https://github.com/facebook/react-native/issues/23306
<img width="798" alt="スクリーンショット 2019-03-03 15.15.11.png" src="https://qiita-image-store.s3.amazonaws.com/0/42587/cb01e72e-ee5a-2a31-7e50-97d92b2a180e.png">

**最新のバージョンだとちゃんと動かないぽい・・・？？**

# 対応

プロジェクトを作り直す

```shell
$ cd ..                                                                                                                                                                               (hello_world) 15:05:28
$ rm -rf hello_world/                                                                                                                                                                (react_native) 15:05:30
$ react-native init  --version="0.57.3" hello_world
This will walk you through creating a new React Native project in /Users/hondy12345/projects/react_native/hello_world
Installing react-native@0.57.3...
Consider installing yarn to make this faster: https://yarnpkg.com

> fsevents@1.2.7 install /Users/hondy12345/projects/react_native/hello_world/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
[fsevents] Success: "/Users/hondy12345/projects/react_native/hello_world/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN react-native@0.57.3 requires a peer of react@16.6.0-alpha.8af6728 but none is installed. You must install peer dependencies yourself.

+ react-native@0.57.3
added 794 packages from 377 contributors and audited 16370 packages in 19.761s
found 6 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
Setting up new React Native app in /Users/hondy12345/projects/react_native/hello_world
Installing React...
+ react@16.6.0-alpha.8af6728
added 2 packages and audited 16383 packages in 4.591s
found 6 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
Installing Jest...
+ metro-react-native-babel-preset@0.53.0
+ babel-jest@24.1.0
+ jest@24.1.0
+ react-test-renderer@16.6.0-alpha.8af6728
added 475 packages from 263 contributors, updated 2 packages and audited 91871 packages in 12.354s
found 6 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
To run your app on iOS:
   cd /Users/hondy12345/projects/react_native/hello_world
   react-native run-ios
   - or -
   Open ios/hello_world.xcodeproj in Xcode
   Hit the Run button
To run your app on Android:
   cd /Users/hondy12345/projects/react_native/hello_world
   Have an Android emulator running (quickest way to get started), or a device connected
   react-native run-android
```

# 再挑戦

```shell
$ react-native run-android                                                                                                                                                            (hello_world) 15:11:51
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Downloading https://services.gradle.org/distributions/gradle-4.4-all.zip
..............................................................................................
Unzipping /Users/hondy12345/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4-all.zip to /Users/hondy12345/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1
Set executable permissions for: /Users/hondy12345/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4/bin/gradle

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '11'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
```

**おや・・・？**

# Javaのバージョンが指定されてないっぽい

`bash` の場合はこう書けばいいが、

```bash
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
```

`fish` を利用しているため、こう書く

```fish
$ set -x JAVA_HOME (/usr/libexec/java_home -v 1.8)
```

# 再々挑戦

```ssh
$ react-native run-android                                                                                                                                                            (hello_world) 15:11:51
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Samsung Galaxy S9 - 8.0.0' for app:debug
Installed on 1 device.


BUILD SUCCESSFUL in 2s
27 actionable tasks: 1 executed, 26 up-to-date
Running /Users/hondy12345/Library/Android/sdk/platform-tools/adb -s 192.168.56.101:5555 reverse tcp:8081 tcp:8081
Starting the app on 192.168.56.101:5555 (/Users/hondy12345/Library/Android/sdk/platform-tools/adb -s 192.168.56.101:5555 shell am start -n com.hello_world/com.hello_world.MainActivity)...
Starting: Intent { cmp=com.hello_world/.MainActivity }
```

**動いた！！**