環境
Winows 10 64bit
Node.js v14.7.0
react-native @ 0.63.2
エラー内容
> npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 967 file(s) to forward-jetify. Using 8 workers...
info Starting JS server...
info Installing the app...
FAILURE: Build failed with an exception.
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
* 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
BUILD FAILED in 6s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
原因
OpenJDK14以降を使う場合は、gradleを6.3で指定しないとダメらしいです
対処方法
以下、2020/08/25現在の対処法
現在最新のgradleは6.6なのでそれにしました
android/gradle/wrapper/gradle-wrapper.properties
--- distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
+++ distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
参考
https://stackoverflow.com/questions/60844245/how-solve-could-not-initialize-class-org-codehaus-groovy-reflection-reflectionc
https://github.com/gradle/gradle/issues/10248