在Android模拟器上运行react-native [英] Run react-native on android emulator

查看:369
本文介绍了在Android模拟器上运行react-native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Mac上的genymotion android模拟器上运行react-native应用程序。
当我写 react-native run-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$ 

然后我试过:


  1. react-native开始

  2. react-native run-android

  1. react-native start
  2. react-native run-android

相同的结果。

然后我尝试了:


  1. react-native包--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反向tcp:8081 tcp:8081 ,它说错误:已关闭

当我尝试在android-sdk模拟器上运行应用程序时,上面得到了相同的错误,但没有错误:已关闭

When I try to run app on android-sdk emulator it gets the same error above but without error: closed.

在android studio中,我可以运行此应用,并且它可以在genymotion上运行。
请告诉我如何在android模拟器上运行我的应用程序?

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:


  1. 请按如下所示安装所需的SDK此图

配置所需的SDK


  1. 如果已经安装了它,则必须更新以下SDK: b
    $ b

    • Android SDK工具(将其更新为最新版本)

    • Android SDK平台工具(将其更新为最新版本)

    • Android SDK生成工具(将其更新到最新版本)

    • Android支持存储库 Extra
  1. 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 under Extra folder (update it to latest version)




注意:支持库的本地Maven存储库,在React的官方文档中列为SDK要求-native现在在SDK Manager中被命名为Android Support Repository。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆