React Native 运行报错 ---- SDK location not found

React Native 环境搭建完成,创建项目后,

运行报错:

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 f ile 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: 13.533 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/getting-started.html

两种解决方法:

(一) 添加系统环境变量 ANDROID_HOME 指向 Android SDK 的安装目录

以win7设置环境变量为例

(二)在react-native 项目 android文件夹下新建 local.properties 文件 内容如下 (或者从已有的android项目中直接copy过来)

sdk.dir=D:\Android\sdk

经验分享 程序员 微信小程序 职场和发展