react native android 踩坑記

運(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了。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容