将我们的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
注意:
0.57.8
和本机分支^2.3.3
),此崩溃不存在。更新:来自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')
}
答案 0 :(得分:0)
我通过从项目中删除react-native-branch
来“修复”此问题。事实证明,我们不再使用它了,所以幸运的巧合:)