question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashes on receving notification

See original GitHub issue

I am using this package with expokit (detached). On sending the notifictaion the app crashes. I searched around to find that adding

compile 'com.google.firebase:firebase-messaging:11.8.0'

worked for some. But in my case it produces

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Here’s the app/build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.wow.wow"
        minSdkVersion 19
        targetSdkVersion 25
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        manifestPlaceholders = [
                'appAuthRedirectScheme': 'com.wow.wow'
        ]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "8g"
    }
    lintOptions {
        abortOnError false
    }
}

task exponentPrebuildStep(type: Exec) {
    workingDir '../../'

    if (System.getProperty('os.name').toLowerCase().contains('windows')) {
        commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
    } else {
        commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
    }
}
preBuild.dependsOn exponentPrebuildStep

repositories {
    flatDir {
        dirs 'libs'
    }
    mavenLocal()
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    compile (project(':react-native-fcm'))   {
        exclude group: 'com.google.android.gms'
        exclude group: "com.google.firebase"
    }

    compile 'com.google.firebase:firebase-core:11.8.0' //this decides your firebase SDK version
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.android.support:multidex:1.0.1'


    compile('host.exp.exponent:expoview:23.0.0@aar') {
        exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
        exclude group: 'com.facebook.android', module: 'audience-network-sdk'
        exclude group: 'io.nlopez.smartlocation', module: 'library'
        transitive = true;
    }

    compile 'com.facebook.android:facebook-android-sdk:4.+'
    compile('com.facebook.android:audience-network-sdk:4.+') {
        exclude module: 'play-services-ads'
    }
    compile('io.nlopez.smartlocation:library:3.2.11') {
        transitive = false
    }


}
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.google.android.gms'
                && ( (details.requested.name == 'play-services-base') || (details.requested.name == 'play-services-maps') ) ) {
            details.useVersion '11.8.0'
        }
        if (details.requested.group == 'com.google.firebase') {
            details.useVersion '11.8.0'
        }
    }
}
apply plugin: 'com.google.gms.google-services'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
ohsory1324commented, Feb 26, 2018

@anish000kumar I used this trick. I’m not good at Java so I can’t be sure this code is good. But my problem was solved.

public class MainApplication extends MultiDexApplication implements ReactApplication {
  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
      new FIRMessagingPackage()
    );
  }

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new FIRMessagingPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }
}
0reactions
evollucommented, Feb 26, 2018

implements ReactApplication should solve the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes after receiving notification using @react-native ...
Iam trying to implement notification using @react-native-firebase/messaging in react native app.The App returns the FCM token ,but when a ...
Read more >
[Android] Native crash if a push notification has been received
Issue Hi there. Let me describe the problem. I am using react-native-firebase and firebase console in order to send push notifications.
Read more >
[Solved] Android app crash when one signal notification sent
My App Crash every time I send a One Signal Push notification. note: firebase has no issue also one signal inApp message working...
Read more >
2.8.31 - Crash when opening a push notification and app not ...
I'm seeing a crash on app startup after opening a push notification. It only seems to happen when the app is not running...
Read more >
IOS 10 crashes caused by Local Notification - Apple Developer
You might want to try running your app in the simulator. Doing so presented a crash report automatically for me. I could also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found