리엑트 네이티브에서 npm run android 명령어를 실행했을 경우 다음과 같은 에러가 났다.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/jongyeol/WebstormProjects/anytimeProject/android/local.properties'.
처음에 에러를 발견하고 Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 이 명령어를 구글에 검색하였으나 별다른 해답을 찾을 수 없었다. 그 후 *what went wrong에 더 자세히 에러가 표시되어 있어서 Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'. 를 구글에 검색해 보았다.
하지만 galdle의 버전문제, 라이센스 문제와 같은 답변들이 많이 나와있었고, 나중에서야 나와 관련 없는 답이라는 것을 알게 되었지만 이러한 답변들을 일일히 해석하고 찾아보느라 오히려 시간을 낭비했다.
그 후 마지막으로 가작 밑에 나와 있는 에러표시인 SDK location not found. Define location with an ANDROID_SDK_ROOT ~ 를 구글해 검색해 보니 android/local.properties 폴더를 만들고 그곳에 sdk 경로를 다음과 같이
sdk.dir = /Users/[mac 유저네임]/Android/sdk
지정해 줘야 한다는 해답을 찾을 수 있었다. 최대한 구체적으로 보이는 에러 메세지를 찾고 그것을 통해 검색하는 것이 삼천포로 빠지지 않는 방법이라는 것을 깨달았다.
'React-Native' 카테고리의 다른 글
react native kakao login 에러 해결 (0) | 2023.10.03 |
---|---|
[RN] 자동으로 android emulator 가 켜지지 않을때 (0) | 2022.05.16 |
[RN] AutoHeightWebview crash with navigation (0) | 2022.05.10 |