運(yùn)行環(huán)境
操作系統(tǒng):macOS Sierra 10.12.1
jdk版本:1.8.0_101
項目運(yùn)行報錯(react-native run-android)
根據(jù)網(wǎng)上教程,安裝了安卓運(yùn)行環(huán)境,初始化項目執(zhí)行react-native run-android
本以為一切會順利,結(jié)果報如下錯誤
Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
.
.
.
.
.
* What went wrong:
A problem occurred evaluating 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.
BUILD FAILED
Total time: 18.729 secs
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/android-setup.html

anderror1.jpeg

anderror2.jpeg
??但是經(jīng)過仔細(xì)對照?官網(wǎng)和網(wǎng)上資料,發(fā)現(xiàn)我的環(huán)境并沒有問題,后來在 stackoverflow 上找到了 答案
具體做法是:在項目中 andorid?文件夾下新建一個名為local.properties 的文件
內(nèi)容寫:
sdk.dir=?你的sdk的路徑
保存后重新運(yùn)行項目就ok了。