无法将 Android 模拟器连接到 React Native 调试器

Unable to connect Android emulator to React Native debugger

我无法将 android 模拟器与 React 本机调试器连接。

当我 运行 react-native run-android 时,它成功启动了应用程序,没有显示任何错误。它还会启动节点 Metro Bundler。但它没有在 RN 调试器中打印任何日志。当我在页面上按 Reload app 时,它显示以下弹出错误:

React Native: No apps connected
Sending 'reload' to all React Native apps failed. Make sure your app is running in the simulator or on a phone

Popup error when press on RN debugger "Reload app" button

我试过 运行宁此 adb reverse tcp:8081 tcp:8081 但它不起作用。当我在模拟器中按 Cmd+m 时,它显示多点触控。所以我也打不开开发者菜单。

unintentional triggered when pressed Cmd+m

System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 60.96 MB / 8.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.12.0 - /usr/local/bin/node
    npm: 6.12.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 27, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.6010548
    Xcode: 11.3/11C29 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: ^0.61.5 => 0.61.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1

我该如何解决这个问题?

模拟器是指真机还是Android工作室?

如果您尝试从 android studio 连接模拟器,请卸载设备并安装 Pixel 2,它可能对您有所帮助。

并卸载 React 本机调试器并安装最新的

问题是我的 RN 版本从 0.59 更新到 0.6 后页面无法正常加载。我相信它还有一些其他问题,因为我从一开始就没有在 android 中进行过测试。所以,我刚刚创建了一个新项目并手动导入了所有文件。可能不是您正在寻找的答案,但解决了问题。