2

将我们的 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')
}
4

2 回答 2

0

react-native-branch我通过从项目中删除来“修复”这个问题。事实证明我们不再使用它了,真是幸运的巧合:)

于 2019-07-15T21:38:01.683 回答
0

react-native reanimated 对您的应用执行此操作,chrome 不支持 reanimated 并在调试模式下使您的应用崩溃

于 2021-12-29T09:56:29.227 回答