我尝试在我的 mac 上的 genymotion android 模拟器上运行 react-native 应用程序。当我写 react-native run-android
它得到
Running /usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081
error: closed
Could not run adb reverse: Command failed: /usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Building and installing the app on the device (cd android && ./gradlew installDebug...
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
MacBook-Pro-MacBook:ART-CarefulPeople macbook$
然后我试过了:
react-native start
react-native run-android
同样的结果。
然后我试过了:
react-native bundle --entry-file index.android.js --platform android --bundle-output android/app/src/main/assets/index.android.bundle
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"
react-native run-android
同样的结果。
我试过了 adb reverse tcp:8081 tcp:8081
它说 error: closed
当我尝试在 android-sdk 模拟器上运行应用程序时,它会出现上述相同的错误,但没有 error: closed
。
从 android studio 我可以运行这个应用程序,它适用于 genymotion。请告诉我,我应该怎么做才能在 android 模拟器上运行我的应用程序?
原文由 alborozd 发布,翻译遵循 CC BY-SA 4.0 许可协议
我有一个类似的问题,在花了这么多时间和大量搜索这个问题之后,唯一对我有用的技巧:
Configure Required SDKs
Android SDK Tool
(更新到最新版本)Android SDK Platform-tools
(更新到最新版本)Android SDK Build-tools
(更新到最新版本)Android Support Repository
Extra
文件夹下(更新到最新版本)Android API
as the installedAndroid SDK Build-tools
&Android SDK Platform-tools
version as shown in theConfigure Required SDKs
figure above.