Command failed: gradlew.bat installDebug

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

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值