2

After upgrading our react-native project to react-native 0.59.10 I am experiencing a crash when running the Android version. The app builds, installs and runs fine, but it crashes when trying to connect to a remote debugger (react-native-debugger or Chrome). This affects Android only, iOS works fine. Here is what adb logcat '*:E' reports when the crash occurs:

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)

Here is some relevant info about the environment from package.json

"dependencies": {
...
"react-native-branch": "3.0.1",
...

From 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", "" 
        }
        ...

From 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')
    }
}

From gradle-wrapper.properties:

...
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
...

react-native info:

  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

NOTES:

  • before the upgrade (react-native 0.57.8 and react-native-branch ^2.3.3), this crash was not present.
  • the crash happens both when running in the emulator and running on USB connected device

UPDATE: dependencies from 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')
}
dudeinthemirror
  • 537
  • 4
  • 15
  • Just to clarify, this only crashes when remote debugging is turned on? Have you tried going back and forth between remote debugging and not? I ask because I had a similar issue with crashing on launch that going back and forth gave me a little more information on why it was crashing. – Doug Watkins Jul 10 '19 at 15:49
  • So, the sequence is: start the app, then simulate the shake gesture to display the dev popup, then I tap on `Debug JS Remotely` and the app crashes. From that point on, when trying to restart the app, it just crashes. The only way out of that is to uninstall the app and re-install – dudeinthemirror Jul 10 '19 at 16:28
  • Can you share a screenshot of the crash? On my devices, If I crash and have the red screen up, I can still bring up the dev menu to turn off debug js remotely. – Doug Watkins Jul 10 '19 at 17:52
  • That's the other odd thing: there is no "red screen of death" appearing. The app just goes away (just like a crash of a non-debug variant) – dudeinthemirror Jul 10 '19 at 18:35
  • I just did an upgrade of react-native, and had a weird crash (different, but who knows?). I fixed it with `cd android && ./gradlew clean` and then rebuilt the app. – Laurent S Jul 10 '19 at 18:38
  • Yes, that's what I do when I build: `./gradlew -stop; ./gradlew clean && ./gradlew assembleDebug --stacktrace`. And then run with: `react-native run-android --variant=debug --appIdSuffix 'debug'` – dudeinthemirror Jul 10 '19 at 19:08
  • Can you show your dependencies from `app/build.gradle`? – Doug Watkins Jul 10 '19 at 19:42
  • Yes, I appended those to the description under `UPDATE` – dudeinthemirror Jul 10 '19 at 20:25

2 Answers2

0

I "fixed" this by removing react-native-branch from the project. It turns out we are not using it anymore, so lucky coincidence :)

dudeinthemirror
  • 537
  • 4
  • 15
0

react-native reanimated do this with your app, chrome does not support the reanimated and crash your app on debug mode

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/30695789) – CodeChanger Jan 03 '22 at 12:39