我正在尝试在react-native中创建我的应用程序的调试版本。在我使用VSCode文本编辑器的react-native-tools扩展包并附加了调试器进行调试之后,它就可以正常工作并且开始出现问题。创建发行版本时不会发生该错误。我删除了扩展名,删除了项目的node_modules文件夹,然后重新安装。
错误如下:
08-30 13:15:42.896 6228-6491/? E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare()
08-30 13:15:42.957 25112-25112/? E/art: Failed to send JDWP packet APNM to debugger (-1 of 51): Broken pipe
08-30 13:15:42.961 25112-25118/? E/art: Failed sending reply to debugger: Broken pipe
08-30 13:15:43.052 25112-25138/? E/Theme: Different package name.com.namahapp,com.google.android.gms
08-30 13:15:43.110 25112-25151/? E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare()
08-30 13:15:43.155 18392-18909/? E/Theme: Different package name.com.facebook.katana,com.google.android.gms
08-30 13:15:43.246 18666-22557/? E/NetworkScheduler: Invalid component specified.
08-30 13:15:43.332 25112-25165/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.namahapp, PID: 25112
java.lang.NoClassDefFoundError: com.facebook.react.modules.fresco.SystraceRequestListener
at com.facebook.react.modules.fresco.FrescoModule.getDefaultConfigBuilder(FrescoModule.java:149)
at com.facebook.react.modules.fresco.FrescoModule.getDefaultConfig(FrescoModule.java:138)
at com.facebook.react.modules.fresco.FrescoModule.initialize(FrescoModule.java:101)
at com.facebook.react.bridge.ModuleHolder.doInitialize(ModuleHolder.java:198)
at com.facebook.react.bridge.ModuleHolder.markInitializable(ModuleHolder.java:86)
at com.facebook.react.bridge.NativeModuleRegistry.notifyJSInstanceInitialized(NativeModuleRegistry.java:123)
at com.facebook.react.bridge.CatalystInstanceImpl$2.run(CatalystInstanceImpl.java:387)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:152)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:818)
本机版本为0.55.4。 我的package.json文件是:
{
"name": "NamahApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-check-app-install": "0.0.4",
"react-native-fbsdk": "^0.7.0",
"react-native-firebase": "^4.2.0",
"react-native-keyboard-aware-scroll-view": "^0.6.0",
"react-native-linear-gradient": "^2.4.0",
"react-native-shadow": "^1.2.2",
"react-native-share": "^1.0.27",
"react-native-snap-carousel": "^3.7.2",
"react-native-sound": "^0.10.9",
"react-native-svg": "^6.5.0",
"react-navigation": "^2.0.1",
"socketcluster-client": "^13.0.0"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./app/assets/fonts/"
]
}
}
我无法确定错误是什么以及如何解决。任何帮助表示赞赏。谢谢。
更新31/08/2018
我打开文件时出现错误,发现该文件在两个地方可用:
C:\Users\Nikhil\.gradle\caches\modules-2\files-2.1\com.facebook.react\react-native\0.12.0\8a53a72920675231a5d11880ae3cacb9ab91b93c\react-native-0.12.0-sources.jar!\com\facebook\react\modules\fresco\FrescoModule.java
在“用户”文件夹(Windows)中。G:\path\to\project\node_modules\react-native\android\com\facebook\react\react-native\0.55.0\react-native-0.55.0-sources.jar!\com\facebook\react\modules\fresco\FrescoModule.java
在Users
文件夹中的文件中没有SystraceRequestListener.java
文件。
此外,路径中的react-native版本为0.12.0。如何设置?我该如何更改?我猜应该是0.55.4,即项目中使用的当前本机版本。
我应该在哪里进行更改??在项目中?或在Android Studio基本设置中?
请帮助...
Update-2 31/08/18
从Users
文件夹中删除了.gradle / cache文件,但错误仍然存在。
现在,该错误肯定是在项目的.gradle文件夹中。
现在,即使SystraceRequestListener.java
与发生错误的文件位于同一文件夹(即FrescoModule.java
)中,也需要确定为什么会发生错误。
更新18年9月3日(9月3日)
我重新安装并配置了项目中使用的所有npm软件包,以查找构建何时出现上述错误,并且发现当我安装react-native-firebase时出现了问题。如果找到解决方案,将会更新。
答案 0 :(得分:0)
错误是从react-native-firebase软件包中出现的。
将react-native-firebase软件包更新到最新版本解决了我的问题。