在react-native run-android启动模拟机的时候,报错如下:
1 2 3 4 5 6 7 |
BUILD FAILED in 5s 13 actionable tasks: 1 executed, 12 up-to-date 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. Run CLI with --verbose flag for more detail |
首先,确保你有一个运行android模拟器。要做到这一点,你运行adb devices,查看是否可以看到你的设备,出现如下图所示 类似*** device就代表连接设备成功

react-native启动报错error Could not install the app on the device...解决方法
adb kill-server 关闭adb服务,然后在启动安卓机试一下,react-native run-android
要是还是不行的话,就如下操作尝试:
- 从项目中删除Android和iOS文件夹
- 运行'react-native eject',这将重新添加平台
- react-native run-android --deviceId emulator-5554 最后面是指定设备(adb devices =>设备列表:emulator-5554这个是动态的,你要根据你设备的来)
注意:在某些情况下,您可能必须执行以下操作:
- 清晰的守望者手表:watchman watch-del-all。
- 删除node_modules文件夹:rm -rf node_modules && npm install。
- 重置Metro Bundler缓存:rm -rf /tmp/metro-bundler-cache-*或npm start -- --reset-cache。
- 删除急速缓存:rm -rf /tmp/haste-map-react-native-packager-*。