android-sdk does not exist

react-native 프로젝트 실행을 할 때 다음과 같이 에러가 나오는 경우

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/usr/local/opt/android-sdk' does not exist.

* 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 1s

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/usr/local/opt/android-sdk' does not exist.

* 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 1s

    at checkExecSyncError (child_process.js:621:11)
    at execFileSync (child_process.js:639:15)
    at runOnAllDevices (/Users/victor/react_test/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/Users/victor/react_test/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:169:41)
    at /Users/victor/react_test/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:135:12
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
    at async Command.handleAction (/Users/victor/react_test/node_modules/react-native/node_modules/@react-native-community/cli/build/cliEntry.js:160:7)

.bash_profile에 다음 환경 설정을 추가한다.

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools

참고

Leave a Reply