搖晃安卓設備并點擊除錯,它每次都立即崩潰。從 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)
相同的本機代碼庫,在 ios 上打開 dubug 模式作業正常,但在 Android 上它總是在打開除錯模式時崩潰。我看不到錯誤日志是什么原因造成的。
這是我對本機應用程式的依賴項,我正在使用 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"
},
uj5u.com熱心網友回復:
經過更多的搜索,發現這是 react-native-reanimated 中的一個已知問題。正如他們的網站指出的那樣
請注意,Reanimated 2 不支持遠程除錯,只能使用 Flipper 進行除錯。
另一個github issue也指出了這個問題
這是意料之中的,您不能對 turbomodules(Reanimated v2 正在使用)使用遠程除錯。查看 Flipper 以除錯您的應用程式。
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中的相關代碼
- 紗線安裝或 npm 安裝
- 轉到 ios 檔案夾并運行
pod install - 進入 android 檔案夾并運行
./gradlew clean - 重建應用程式。
yarn android和yarn ios
另一種選擇是使用 Flipper 進行除錯。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/391732.html
