gpt4 book ai didi

android - React Native Android 在启用 Debug模式时崩溃

转载 作者:行者123 更新时间:2023-12-04 23:40:41 24 4
gpt4 key购买 nike

摇晃android设备并点击Debug,每次它都会立即崩溃。从 Android Studio logcat 中,它显示 没有加载源 URL,你初始化实例了吗? :

java.lang.AssertionError: No source URL loaded, have you initialised the instance?
at com.facebook.infer.annotation.Assertions.assertNotNull(Assertions.java:35)
at com.facebook.react.modules.debug.SourceCodeModule.getTypedExportedConstants(SourceCodeModule.java:39)
at com.facebook.fbreact.specs.NativeSourceCodeSpec.getConstants(NativeSourceCodeSpec.java:35)
at com.facebook.react.bridge.JavaModuleWrapper.getConstants(JavaModuleWrapper.java:129)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
at java.lang.Thread.run(Thread.java:923)
相同的 react 原生代码库,在 ios 上打开 dubug 模式工作正常,但在 Android 上,打开 Debug模式时它总是崩溃。我看不到错误日志的原因。
这是我对 react native 应用程序的依赖项,我正在使用 redux 和 redux-devtools-extension 进行调试。我错过了任何图书馆吗?
"dependencies": {
"@react-native-async-storage/async-storage": "^1.15.14",
"@reduxjs/toolkit": "^1.7.0",
"expo": "~42.0.1",
"expo-permissions": "12.1.0",
"expo-splash-screen": "~0.11.2",
"expo-status-bar": "~1.0.4",
"expo-updates": "~0.8.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.64.1",
"react-native-fast-image": "^8.5.11",
"react-native-gesture-handler": "~1.10.2",
"react-native-navigation": "^7.14.0",
"react-native-reanimated": "~2.1.0",
"react-native-screens": "3.2.0",
"react-native-unimodules": "~0.13.3",
"react-native-web": "0.16.3",
"react-redux": "^7.2.6",
"redux-persist": "^6.0.0",
"tslint": "^6.1.3",
"tslint-react": "^5.0.0"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@types/react": "17.0.5",
"@types/react-native": "0.64.5",
"babel-preset-expo": "~8.3.0",
"jest-expo": "~41.0.0",
"redux-devtools-extension": "^2.13.9",
"typescript": "4.2.4"
},

最佳答案

经过一番搜索,发现这是 react-native-reanimated 中的一个已知问题。作为他们的website指出

Please note that Reanimated 2 doesn't support remote debugging, onlyFlipper can be used for debugging.


另一个 github issue也指出了这个问题

This is expected, you can't use remote debugging with turbomodules(which Reanimated v2 is using). Check out Flipper to debug your app.

https://docs.swmansion.com/react-native-reanimated/docs/#known-problems-and-limitations


https://github.com/software-mansion/react-native-reanimated/issues/1990
删除这个库解决了这个问题。
  • 删除 package.json
  • 中的 react-native-reanimated 依赖项
  • 删除android的MainApplication.java中的相关代码
  • yarn install 或 npm install
  • 转到 ios 文件夹并运行 pod install
  • 转到 android 文件夹并运行 ./gradlew clean
  • 重建应用程序。 yarn androidyarn ios

  • 另一种选择是使用 Flipper 进行调试。

    关于android - React Native Android 在启用 Debug模式时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70405285/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com