尝试连接到 react-native-debugger 或 Chrome 时崩溃
Posted
技术标签:
【中文标题】尝试连接到 react-native-debugger 或 Chrome 时崩溃【英文标题】:Crash when trying to connect to react-native-debugger or Chrome 【发布时间】:2019-11-20 06:57:48 【问题描述】:将我们的 react-native 项目升级到 react-native 0.59.10
后,我在运行 android 版本时遇到了崩溃。该应用程序可以正常构建、安装和运行,但在尝试连接到远程调试器(react-native-debugger 或 Chrome)时会崩溃。这仅影响 Android,ios 工作正常。
以下是发生崩溃时adb logcat '*:E'
报告的内容:
7-09 18:01:10.822 9024 9115 E AndroidRuntime: Process: com.acme.ifa.debug, PID: 9024
07-09 18:01:10.822 9024 9115 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lio/branch/referral/util/BRANCH_STANDARD_EVENT;
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at io.branch.rnbranch.RNBranchModule.getConstants(RNBranchModule.java:262)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at com.facebook.react.bridge.JavaModuleWrapper.getConstants(JavaModuleWrapper.java:136)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:873)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:232)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "io.branch.referral.util.BRANCH_STANDARD_EVENT" on path: DexPathList[[zip file "/data/app/com.acme.ifa.debug-lIhzIdDgqfx74SieP8wwnw==/base.apk"],nativeLibraryDirectories=[/data/app/com.acme.ifa.debug-lIhzIdDgqfx74SieP8wwnw==/lib/x86, /data/app/com.acme.ifa.debug-lIhzIdDgqfx74SieP8wwnw==/base.apk!/lib/x86, /system/lib]]
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
07-09 18:01:10.822 9024 9115 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
这里有一些来自package.json
的环境相关信息
"dependencies":
...
"react-native-branch": "3.0.1",
...
来自android/app/build.gradle
defaultConfig
applicationId "com.acme.ifa"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 176
versionName "2.6.5"
resValue "string", "build_config_package", "com.acme.ifa"
...
buildTypes
debug
applicationIdSuffix "debug"
multiDexEnabled false
signingConfig signingConfigs.debug
resValue "string", "deployment_key", ""
...
来自android/build.gradle
:
buildscript
ext
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = '28.0.0'
repositories
jcenter()
mavenCentral()
google()
dependencies
classpath('com.android.tools.build:gradle:3.4.0')
classpath('com.google.gms:google-services:3.1.1')
来自gradle-wrapper.properties
:
...
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
...
反应原生信息:
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 601.60 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.4.0 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.0, 28.0.1, 28.0.2, 28.0.3
System Images: android-25 | Google APIs Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.10 => 0.59.10
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
react-native-rename: 2.2.2
注意事项:
在升级(react-native0.57.8
和 react-native-branch ^2.3.3
)之前,不存在此崩溃。
在模拟器中运行和在 USB 连接设备上运行时都会发生崩溃
更新:来自 android/app/build.gradle 的依赖项:
dependencies
implementation project(path:':@react-native-community_netinfo', configuration:'default')
implementation project(path:':react-native-webview', configuration:'default')
implementation project(path:':mobile-orientation-lock', configuration:'default')
implementation project(path:':react-native-detect-navbar-android', configuration:'default')
implementation project(path:':mobile-custom-webview', configuration:'default')
implementation project(path:':react-native-fs', configuration:'default')
implementation project(path:':react-native-reanimated', configuration:'default')
implementation project(path:':react-native-branch', configuration:'default')
implementation project(path:':react-native-vector-icons', configuration:'default')
implementation project(path:':react-native-splash-screen', configuration:'default')
implementation project(path:':react-native-gesture-handler', configuration:'default')
implementation project(path:':react-native-config', configuration:'default')
implementation project(path:':react-native-linear-gradient', configuration:'default')
implementation project(path:':react-native-immersive', configuration:'default')
implementation project(path:':react-native-i18n', configuration:'default')
implementation project(path:':react-native-device-info', configuration:'default')
implementation project(path:':react-native-code-push', configuration:'default')
implementation project(path:':react-native-camera', configuration:'default')
implementation('com.google.zxing:core:3.3.2')
implementation('org.jetbrains.kotlin:kotlin-stdlib:1.2.71')
implementation('com.google.code.gson:gson:2.8.5')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('androidx.appcompat:appcompat:$rootProject.ext.supportLibVersion')
implementation('com.facebook.fresco:fresco:1.10.0')
implementation('com.facebook.fresco:animated-gif:1.10.0')
implementation('com.facebook.react:react-native:+') // From node_modules
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar')
transitive = true
implementation('com.google.android.gms:play-services-analytics:12.0.1')
implementation('androidx.multidex:multidex:2.0.0')
【问题讨论】:
澄清一下,只有在打开远程调试时才会崩溃?您是否尝试过在远程调试之间来回切换?我之所以问,是因为我在启动时遇到了类似的崩溃问题,来回运行为我提供了有关崩溃原因的更多信息。 所以,顺序是:启动应用程序,然后模拟摇晃手势以显示开发弹出窗口,然后我点击Debug JS Remotely
,应用程序崩溃。从那时起,当尝试重新启动应用程序时,它就会崩溃。解决这个问题的唯一方法是卸载应用程序并重新安装
你能分享崩溃的截图吗?在我的设备上,如果我崩溃并出现红屏,我仍然可以调出开发菜单来远程关闭调试 js。
这是另一件奇怪的事情:没有出现“红屏死机”。该应用程序就消失了(就像非调试变体的崩溃一样)
我刚刚升级了 react-native,但发生了奇怪的崩溃(不同,但谁知道呢?)。我用cd android && ./gradlew clean
修复了它,然后重建了应用程序。
【参考方案1】:
我通过从项目中删除 react-native-branch
来“修复”这个问题。事实证明我们不再使用它了,真是幸运的巧合:)
【讨论】:
【参考方案2】:react-native reanimated 对您的应用执行此操作,chrome 不支持 reanimated 并在调试模式下使您的应用崩溃
【讨论】:
这并没有提供问题的答案。一旦你有足够的reputation,你就可以comment on any post;相反,provide answers that don't require clarification from the asker。 - From Review以上是关于尝试连接到 react-native-debugger 或 Chrome 时崩溃的主要内容,如果未能解决你的问题,请参考以下文章
在 react-native-debugger 中配置 redux 存储的初始状态?
更新 react-native 后无法使用 react-native-debugger
无法连接到数据库(HY000/1045),尝试使用 php mysqli_connection 连接到数据库 [重复]
Celery sqs 尝试连接到 amqp:无法连接到 amqp://guest:**@127.0.0.1:5672//