난 분명히
react-native init test
yarn android
를 순서대로 했지만 iOS는 잘된 반면 안드로이드는 아래와 같은 에러가 발생했다.
iuchan@MacBook-Pro sdf % yarn android
yarn run v1.22.4
$ 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 12 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 613ms
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 app:installDebug -PreactNativeDevServerPort=8081
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
다행히 구글링을 통해 미리 해결한 사람이 있었다.
이유는 jdk버전이 14로 올라가면서 gradle version이 14를 지원하지 않는 상황에 발생한것이다.
해결 방법은 gradle/wrapper/gradle-wrapper.properties
의 gradle 버젼을 올려주는 것이다. 나의 파일은 다음과 같다.
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists