在 android 模拟器上运行 react-native [英] Run react-native on android emulator
问题描述
我尝试在 Mac 上的 genymotion android 模拟器上运行 react-native 应用程序.当我写 react-native run-android
它得到 p>
运行/usr/local/opt/android-sdk/platform-tools/adb 反向 tcp:8081 tcp:8081错误:关闭无法运行 adb reverse:命令失败:/usr/local/opt/android-sdk/platform-tools/adb reverse tcp:8081 tcp:8081在设备上构建和安装应用程序 (cd android && ./gradlew installDebug...无法在设备上安装该应用程序,请阅读上面的错误了解详情.确保您有一个正在运行的 Android 模拟器或已连接的设备设置你的 Android 开发环境:https://facebook.github.io/react-native/docs/android-setup.htmlMacBook-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 模拟器上运行我的应用程序?
我遇到了类似的问题,在花了很多时间和大量搜索这个问题之后,唯一的技巧对我有用:
- 请安装所需的SDK,如图所示
配置所需的 SDK
- 如果您已经安装了它,那么您必须更新以下 SDK:
Android SDK Tool
(更新到最新版本)Android SDK Platform-tools
(更新到最新版本)Android SDK Build-tools
(更新到最新版本)Android Support Repository
Extra
文件夹下(更新到最新版本)
- 您必须至少安装与安装的
Android SDK Build-tools
相同版本的Android API
&Android SDK Platform-tools
版本如上图Configure Required SDKs
所示.
<块引用>
注意:在 React-native 官方文档中列为 SDK 要求的支持库的本地 Maven 存储库现在在 SDK 管理器中命名为 Android 支持存储库.
I try to run react-native app on genymotion android emulator on my mac.
When I write react-native run-android
It gets
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$
Then I've tried:
react-native start
react-native run-android
The same result.
Then I've tried:
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
The same result.
I've tried just adb reverse tcp:8081 tcp:8081
and it says error: closed
When I try to run app on android-sdk emulator it gets the same error above but without error: closed
.
From android studio I can run this app and it works on genymotion. Tell me please what should I do to run my app on android emulator?
I had a similar problem, and after spending so much time and lots of searching about this issue the only trick worked for me:
- Please Install the Required SDKs as shown in this figure
Configure Required SDKs
- If You have already installed it, so you must have to update the following SDKs:
Android SDK Tool
(update it to latest version)Android SDK Platform-tools
(update it to latest version)Android SDK Build-tools
(update it to latest version)Android Support Repository
underExtra
folder (update it to latest version)
- You Must have at least Installed the Same version
Android API
as the installedAndroid SDK Build-tools
&Android SDK Platform-tools
version as shown in theConfigure Required SDKs
figure above.
Note: Local Maven repository for Support Libraries which is listed as the SDK requirement in the official docs of React-native is now named as Android Support Repository in the SDK Manager .
这篇关于在 android 模拟器上运行 react-native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!