React Native App 在尝试远程调试时崩溃,除非重新安装,否则无法再次运行

React Native App crashes when trying to debug remotely and does not work again unless re-installed

应用程序在安装 React-native-Reanimated 库之前工作正常,但在尝试远程调试时开始崩溃 post 安装。除非重新安装并显示此错误,否则它甚至不会重新启动:

Attempt to invoke interface method 'java.lang.String com.facebook.react.bridge.CatalystInstance.getSourceURL()' on a null object reference

该应用程序未启动,但按照 React Reanimated 文档中的安装说明进行了操作,但现在每次我尝试连接到远程调试器时它都会崩溃。

 "dependencies": {
    "@react-native-community/cli": "^6.3.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/native": "^5.9.8",
    "@react-navigation/stack": "^5.14.9",
    "@reduxjs/toolkit": "^1.6.2",
    "axios": "^0.24.0",
    "react": "17.0.2",
    "react-native": "0.66.3",
    "react-native-eject": "^0.1.2",
    "react-native-gesture-handler": "^2.1.0",
    "react-native-image-pan-zoom": "^2.1.12",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-reanimated": "^2.3.0",
    "react-native-safe-area-context": "^3.3.2",
    "react-native-screens": "^3.10.1",
    "react-native-swipe-gestures": "^1.0.5",
    "react-native-vector-icons": "^9.0.0",
    "react-redux": "^7.2.6"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/jest": "^26.0.23",
    "@types/react-native": "^0.66.4",
    "@types/react-native-vector-icons": "^6.4.10",
    "@types/react-test-renderer": "^17.0.1",
    "babel-jest": "^26.6.3",
    "eslint": "^7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2",
    "typescript": "^4.4.4"
  },

好吧,安装 reanimated 2 后似乎无法进行远程调试,改用 Flipper 进行调试

他们的文档中提到 react-native-reanimated 不再可能进行远程调试。

由于库使用 JSI 进行同步本机方法访问,远程调试不再可能。您可以使用 Flipper 调试 JS 代码,但是目前不支持将调试器连接到运行在 UI 线程上的 JS 上下文。

参考:React Native Reanimated Known problems and limitations

要使用 Flipper,请参阅此文档:Debugging React Native apps with Flipper

我也有,只需打开终端右侧的列表框-> select react native: 运行 android。它对我有用。