Command failed: gradlew.bat installDebug

今天学习RN时,根据官网文档一步一步来,然后就报错了。

Command failed: gradlew.bat installDebug_第1张图片

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

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

Command failed: gradlew.bat installDebug

Error: Command failed: gradlew.bat installDebug
    at checkExecSyncError (child_process.js:616:11)
    at Object.execFileSync (child_process.js:634:13)
    at runOnAllDevices (E:\AwesomeProject\node_modules\react-native\local-cli\runAndroid\runAndroid.js:299:19)
    at buildAndRun (E:\AwesomeProject\node_modules\react-native\local-cli\runAndroid\runAndroid.js:135:12)
    at isPackagerRunning.then.result (E:\AwesomeProject\node_modules\react-native\local-cli\runAndroid\runAndroid.js:65:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

就是这个错,我是各种百度啊。由于关心则乱,一直没找到真正解决的原因,我又仔细的看了一下报错信息,发现了这么一句话

A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

意思就是,我的工程没有找到我的SDK位置,然后又是各种百度。终于,我找到了一种解决方式,希望对大家有用。就是,我建议先使用Android Studio打开工程,它会帮你找到正确的SDK路径。然后打开你的React Native工程,打开android目录创建一个文件local.properties文件,写上一句话:

sdk.dir = 你的SDK路径;比如我的 sdk.dir = D:\\sdk 

附上大神网址:https://stackoverflow.com/questions/32634352/react-native-android-build-failed-sdk-location-not-found

 

你可能感兴趣的:(Command failed: gradlew.bat installDebug)