React Native第一次运行报错 error Command failed: gradlew.bat app:installDebug

按照官网上的步骤安装并运行第一个RN项目,没想到出现了下面的错误。

BUILD FAILED in 4m 4s
1 actionable task: 1 executed
error 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
error Command failed: gradlew.bat app:installDebug

首先确定我的设备已经连上了

C:\Users\admin>adb devices
List of devices attached
D5F021***08219        device

后来的解决办法是:
在RN项目下运行执行了yarn add react-native-cli命令
然后把Android项目中local.properties文件拷贝到RN项目Android文件夹中
local.properties内容是sdk目录

sdk.dir=D\:\\AS\\sdk

你可能感兴趣的:(android开发日常)