React-native-firebase: Error only in first launch

Created on 5 May 2018  ·  39Comments  ·  Source: invertase/react-native-firebase

Issue

Error when app is launched (debug and release mode) only the first time.

StackTrace

java.lang.RuntimeException: Unable to instantiate service io.invertase.firebase.messaging.RNFirebaseInstanceIdService: java.lang.ClassNotFoundException: Didn't find class "io.invertase.firebase.messaging.RNFirebaseInstanceIdService" on path: DexPathList[[zip file "/data/app/br.com.gpsoftware.beautyapp-1/base.apk"],nativeLibraryDirectories=[/data/app/br.com.gpsoftware.beautyapp-1/lib/arm,

Environment

  1. Application Target Platform:

macos

  1. Development Operating System:

android

  1. Build Tools:
  1. React Native version:

0.54

  1. RNFirebase Version:
  1. Firebase Module:
Android Messaging

Most helpful comment

I had the same issue, I've fixed it by using:

implementation 'com.google.firebase:firebase-messaging:18.0.0'

which was:

implementation "com.google.firebase:firebase-messaging:17.5.0"

I've tested it with com.google.firebase:firebase-messaging:17.5.0, I can confirm that using 18.0.0 fixed the crash that happens only one time, at starting the app.

I am using "react-native-firebase": "~5.5.0" and implementation "com.google.firebase:firebase-core:16.0.8"

All 39 comments

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**

  • Set this to true to create two separate APKs instead of one:

    • An APK that only works on ARM devices


    • An APK that only works on x86 devices

  • The advantage is the size of the APK is reduced by about 4MB.
  • Upload all the APKs to the Play Store and people will download
  • the correct one based on the CPU architecture of their device.
    */
    def enableSeparateBuildPerCPUArchitecture = false

/**

  • Run Proguard to shrink the Java bytecode in release builds.
    */
    def enableProguardInReleaseBuilds = false

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "br.com.gpsoftware.beautyapp"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 5
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86"
    }
}

signingConfigs {
            release {
                if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                    storeFile file(MYAPP_RELEASE_STORE_FILE)
                    storePassword MYAPP_RELEASE_STORE_PASSWORD
                    keyAlias MYAPP_RELEASE_KEY_ALIAS
                    keyPassword MYAPP_RELEASE_KEY_PASSWORD
                }
            }
        }
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
        }
    }
}

}

dependencies {
compile(project(':react-native-firebase')) {
transitive = false
}

compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"  // From node_modules

// This should be here already
  implementation(project(':react-native-firebase')) {
    transitive = false
  }

  // Firebase dependencies
  implementation "com.google.android.gms:play-services-base:15.0.0"
  implementation "com.google.firebase:firebase-core:15.0.0"
  implementation "com.google.firebase:firebase-auth:15.0.0"
  implementation "com.google.firebase:firebase-messaging:15.0.2"
  implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
  implementation "com.google.firebase:firebase-invites:15.0.0"

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'

I have just checked that if I remove this from manifest the error doesn't occur:

  <service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

Any ideas?

Have you added the RNFirebaseMessagingPackage to your MainApplication.java as explained here? https://rnfirebase.io/docs/v4.0.x/messaging/android#Install-the-RNFirebase-Messaging-package

Yes.
Actually the error only happens if i keep this piece of code in
manifest.xml and only occurs the first time the app is launched.





If I remove this the error doesn't occur.

2018-05-06 12:01 GMT-03:00 Chris Bianca notifications@github.com:

Have you added the RNFirebaseMessagingPackage to your
MainApplication.java as explained here? https://rnfirebase.io/docs/v4.
0.x/messaging/android#Install-the-RNFirebase-Messaging-package


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1054#issuecomment-386885659,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADhovbaCXWMsqIiyQE-AqtmN4__zGzdRks5tvxBfgaJpZM4TzrfN
.

Yes, but you need that in for messaging and notifications to work correctly.
The error implies that the class isn't been found when building, which itself implies that it's not being imported properly.

Adding the messaging module should ensure that this file is included.

The error we get when we try to receive a message:

java.lang.RuntimeException: Unable to instantiate service
io.invertase.firebase.messaging.RNFirebaseMessagingService:
java.lang.ClassNotFoundException: Didn't find class
"io.invertase.firebase.messaging.RNFirebaseMessagingService" on path:
DexPathList[[zip file
"/data/app/br.com.gpsoftware.beautyapp-1/base.apk"],nativeLibraryDirectories=[/data/app/br.com.gpsoftware.beautyapp-1/lib/arm,
/system/fake-libs,
/data/app/br.com.gpsoftware.beautyapp-1/base.apk!/lib/armeabi-v7a,
/system/lib, /vendor/lib]]

 at

android.app.ActivityThread.handleCreateService(ActivityThread.java:3446)

 at android.app.ActivityThread.-wrap6(ActivityThread.java)

 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1725)

 at android.os.Handler.dispatchMessage(Handler.java:102)

 at android.os.Looper.loop(Looper.java:154)

 at android.app.ActivityThread.main(ActivityThread.java:6692)

 at java.lang.reflect.Method.invoke(Native Method)

 at

com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)

 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Caused by: java.lang.ClassNotFoundException: Didn't find class
"io.invertase.firebase.messaging.RNFirebaseMessagingService" on path:
DexPathList[[zip file
"/data/app/br.com.gpsoftware.beautyapp-1/base.apk"],nativeLibraryDirectories=[/data/app/br.com.gpsoftware.beautyapp-1/lib/arm,
/system/fake-libs,
/data/app/br.com.gpsoftware.beautyapp-1/base.apk!/lib/armeabi-v7a,
/system/lib, /vendor/lib]]

 at

dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

 at java.lang.ClassLoader.loadClass(ClassLoader.java:380)

 at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

================
MainApplication.java

package com.appsalaov11;

import android.app.Application;

import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; //
<-- Add this line
import io.invertase.firebase.links.RNFirebaseLinksPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
// <-- Add this line
import io.invertase.firebase.perf.RNFirebasePerformancePackage; // <--
Add this line

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new RNFirebasePackage(),
        new RNFirebaseAuthPackage(),
        new RNFirebaseLinksPackage(),
        new RNFirebaseMessagingPackage(),
        new RNFirebaseCrashlyticsPackage(),
        new RNFirebasePerformancePackage()

  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

2018-05-06 12:08 GMT-03:00 Chris Bianca notifications@github.com:

Yes, but you need that in for messaging and notifications to work
correctly.
The error implies that the class isn't been found when building, which
itself implies that it's not being imported properly.

Adding the messaging module should ensure that this file is included.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1054#issuecomment-386886203,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADhovTCfsAvVJtU8FirV3Qhjy-Yv4izmks5tvxIDgaJpZM4TzrfN
.

Analysing the package i cound't find RNFirebaseMessagingService inside

io.invertase.firebase.messaging

What am I missing?

2018-05-06 12:13 GMT-03:00 Felipe Soares felipe.soares@traderdata.com.br:

The error we get when we try to receive a message:

java.lang.RuntimeException: Unable to instantiate service
io.invertase.firebase.messaging.RNFirebaseMessagingService: java.lang.ClassNotFoundException:
Didn't find class "io.invertase.firebase.messaging.RNFirebaseMessagingService"
on path: DexPathList[[zip file "/data/app/br.com.gpsoftware.
beautyapp-1/base.apk"],nativeLibraryDirectories=[/
data/app/br.com.gpsoftware.beautyapp-1/lib/arm, /system/fake-libs,
/data/app/br.com.gpsoftware.beautyapp-1/base.apk!/lib/armeabi-v7a,
/system/lib, /vendor/lib]]

   at android.app.ActivityThread.handleCreateService(

ActivityThread.java:3446)

   at android.app.ActivityThread.-wrap6(ActivityThread.java)

   at android.app.ActivityThread$H.handleMessage(ActivityThread.

java:1725)

   at android.os.Handler.dispatchMessage(Handler.java:102)

   at android.os.Looper.loop(Looper.java:154)

   at android.app.ActivityThread.main(ActivityThread.java:6692)

   at java.lang.reflect.Method.invoke(Native Method)

   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(

ZygoteInit.java:1468)

   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)

Caused by: java.lang.ClassNotFoundException: Didn't find class

"io.invertase.firebase.messaging.RNFirebaseMessagingService" on path:
DexPathList[[zip file "/data/app/br.com.gpsoftware.beautyapp-1/base.apk"],
nativeLibraryDirectories=[/data/app/br.com.gpsoftware.beautyapp-1/lib/arm,
/system/fake-libs, /data/app/br.com.gpsoftware.beautyapp-1/base.apk!/lib/armeabi-v7a,
/system/lib, /vendor/lib]]

   at dalvik.system.BaseDexClassLoader.findClass(

BaseDexClassLoader.java:56)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:380)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

================
MainApplication.java

package com.appsalaov11;

import android.app.Application;

import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // <-- Add this line
import io.invertase.firebase.links.RNFirebaseLinksPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage; // <-- Add this line
import io.invertase.firebase.perf.RNFirebasePerformancePackage; // <-- Add this line

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new RNFirebasePackage(),
        new RNFirebaseAuthPackage(),
        new RNFirebaseLinksPackage(),
        new RNFirebaseMessagingPackage(),
        new RNFirebaseCrashlyticsPackage(),
        new RNFirebasePerformancePackage()

  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

2018-05-06 12:08 GMT-03:00 Chris Bianca notifications@github.com:

Yes, but you need that in for messaging and notifications to work
correctly.
The error implies that the class isn't been found when building, which
itself implies that it's not being imported properly.

Adding the messaging module should ensure that this file is included.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1054#issuecomment-386886203,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADhovTCfsAvVJtU8FirV3Qhjy-Yv4izmks5tvxIDgaJpZM4TzrfN
.

What version of RNFirebase do you have installed? This is all part of v4+

Where can I check that?

2018-05-06 12:18 GMT-03:00 Chris Bianca notifications@github.com:

What version of RNFirebase do you have installed? This is all part of v4+


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1054#issuecomment-386887031,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADhovXtfn64r90sR6p0ov9pnFpfqs1IGks5tvxRPgaJpZM4TzrfN
.

In your package.json

{
"name": "appsalaov11",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"moment": "^2.22.1",
"native-base": "^2.4.1",
"react": "16.3.0-alpha.3",
"react-moment": "^0.7.0",
"react-native": "0.54.2",
"react-native-elements": "^0.19.1",
"react-native-firebase": "^3.3.1",
"react-native-map-link": "^1.1.1",
"react-native-phone-call": "^1.0.4",
"react-native-router-flux": "^4.0.0-beta.28",
"react-native-ui-kitten": "^3.0.0",
"react-native-user-avatar": "^1.0.3",
"react-native-vector-icons": "^4.5.0",
"react-timer-mixin": "^0.13.3",
"rn-viewpager": "^1.2.9"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.0-alpha.3"
},
"jest": {
"preset": "react-native"
}
}

2018-05-06 12:20 GMT-03:00 Chris Bianca notifications@github.com:

In your package.json


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1054#issuecomment-386887172,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADhovTGcviMuwtq0dvb7YgR5dFcmtNRWks5tvxSygaJpZM4TzrfN
.

Well there you go - you need to update to v4

Thanks a lot. Now it works...

2018-05-06 12:21 GMT-03:00 Chris Bianca notifications@github.com:

Closed #1054
https://github.com/invertase/react-native-firebase/issues/1054.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/invertase/react-native-firebase/issues/1054#event-1611731951,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADhovSnPgLqBqLye3g3L9NXLgepu6yWGks5tvxUQgaJpZM4TzrfN
.

{
"name": "FCM_Example",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-firebase": "^4.2.0"
},
"devDependencies": {
"babel-jest": "23.0.1",
"babel-preset-react-native": "4.0.0",
"jest": "23.1.0",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}

in this case same error is comimg

package com.fcm_example;

import android.app.Application;

import com.facebook.react.ReactApplication;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.auth.RNFirebaseAuthPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

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

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
        new RNFirebasePackage(),
        new RNFirebaseAuthPackage(),
        new RNFirebaseMessagingPackage()
  );
}

@Override
protected String getJSMainModuleName() {
  return "index";
}

};

@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}

@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}

gradle file

dependencies {
compile(project(':react-native-firebase')) {
transitive = false
}
// implementation project(':react-native-firebase')
compile fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:15.0.0"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar' // <-- Add this line if you wish to use badge on Android
implementation "com.google.firebase:firebase-messaging:15.0.2"
}

apply plugin: 'com.google.gms.google-services'

Menifest file

package="com.fcm_example">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />


<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />


 <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
  <action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>






  <!-- //(Optional) Background Messages -->
  <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />

</application>

e error we get when we try to receive a message:

java.lang.RuntimeException: Unable to instantiate service
io.invertase.firebase.messaging.RNFirebaseMessagingService:
java.lang.ClassNotFoundException: Didn't find class
"io.invertase.firebase.messaging.RNFirebaseMessagingService" on path:
DexPathList[[zip file
"/data/app/br.com.gpsoftware.beautyapp-1/base.apk"],nativeLibraryDirectories=[/data/app/br.com.gpsoftware.beautyapp-1/lib/arm,
/system/fake-libs,
/data/app/br.com.gpsoftware.beautyapp-1/base.apk!/lib/armeabi-v7a,
/system/lib, /vendor/lib]]

menifest file

package="com.fcm_example">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />


<application
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/ic_launcher"
  android:allowBackup="false"
  android:theme="@style/AppTheme">
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:windowSoftInputMode="adjustResize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
  <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />


 <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
  <action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>






  <!-- //(Optional) Background Messages -->
  <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />

</application>

I encountered this error out of the blue running react-native-firebase v^4.x on an Android device. I ran npm start -- --reset-cache and rebuilt my project and it went away.

@Pushpi1992 I have the same problem. Did you find a solution to resolve this crash ?

Just got this same error today!
The installation was done and working, but I cleared the cache and reinstalled the packages…
I checked the installation and is done according to https://rnfirebase.io/docs/v4.0.x/messaging/android#Install-the-RNFirebase-Messaging-package

My package.json has: "react-native-firebase": "^5.0.0"

EDIT: reverting from 5.4.0 to 5.2.3 fixed it!

@Manhazito the doc you posted was for v4.0.x, so it may not be correct for v.5.x.x, and v5.3.2+ of react-native-firebase requires react-native 0.59.3+. You have to be very careful of exact dependencies or disaster can strike quickly unfortunately

I had the same issue, I've fixed it by using:

implementation 'com.google.firebase:firebase-messaging:18.0.0'

which was:

implementation "com.google.firebase:firebase-messaging:17.5.0"

I've tested it with com.google.firebase:firebase-messaging:17.5.0, I can confirm that using 18.0.0 fixed the crash that happens only one time, at starting the app.

I am using "react-native-firebase": "~5.5.0" and implementation "com.google.firebase:firebase-core:16.0.8"

@hopewise Thank you for sharing your solution.

I had the exact same issue and updated my "react-native-firebase" version to the latest and also changed the implementation to be 'com.google.firebase:firebase-messaging:18.0.0'

It seems to work fine now, thanks!

I updated per @hopewise's advice, and my crash is gone, Thank you! However, now that I've updated to firebase-messaging:18.0.0, should I "match" my other google/firebase versions? If so, how do I know which versions to choose? Thank you.

    implementation ('com.google.android.gms:play-services-gcm:16.1.0') {
        force = true
    }
    implementation ('com.google.android.gms:play-services-maps:16.1.0') {
        force = true
    }
    implementation ('com.google.android.gms:play-services-location:16.0.0') {
        force = true
    }  
    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:16.0.1"
    implementation "com.google.firebase:firebase-core:16.0.8"
    implementation "com.google.firebase:firebase-messaging:18.0.0"
...
    implementation 'com.facebook.react:react-native:0.59.10'

I have stopped attempting to match all the dependencies on my own and use the new "Bill of Materials" (bom) style. My project looks like this now and it is so much cleaner while maintaining a coherent / tested-together set of versions:

    implementation platform("com.google.firebase:firebase-bom:22.2.0")
    implementation "com.google.firebase:firebase-core"
    implementation "com.google.firebase:firebase-auth"
    implementation "com.google.firebase:firebase-analytics"
    implementation "com.google.firebase:firebase-perf"
    implementation "com.google.firebase:firebase-config"
    implementation "com.google.firebase:firebase-functions"
    implementation "com.google.firebase:firebase-storage"
    implementation "com.google.firebase:firebase-dynamic-links"
    implementation "com.google.firebase:firebase-firestore"
    implementation "com.google.firebase:firebase-messaging"
    implementation 'com.crashlytics.sdk.android:crashlytics'


(note that I may be out of date though - I make an effort to stay current but check android release notes to verify that bom version before just blindly using it)

Thanks, @mikehardy! I was unaware of BOM

Yeah - they're selling it as beta right now so we've been hesitant to put it in the docs but I'm starting to anyway. I have had no problems and it's such a better experience. Glad you like it - cheers

Still facing this issue in react-native-firebase version 5.5.6

@deepas96 how's it work for you on v7.0.1? (the supported version)

No @mikehardy I tried installing the latest version v7.0.1 but it did not work. Still crashing on first launch and on receiving any push notification. Please suggest some fix for this.. It was working fine earlier in v5.5.6 only, but since I added crashlytics to it, It just started crashing.
My react-native version is: "0.59.8"

This issue is closed and super old. I'd suggest opening a new issue with full details, including a full stack trace of the crash from unfiltered logcat (android) or console.app with device plugged in (ios)

I changed the react-native-firebase version to 5.6.0 and updated following things:
In app/build.gradle- implementation 'com.google.firebase:firebase-messaging:+'
In build.gradle - classpath 'com.google.gms:google-services:+'
Earlier they were added with version written as 18.0.0. & 3.2.1 respectively for messaging and google-services.
Now my app did not crash on first launch and not even on receiving notification..

Cheers!!

I have the same problem with @deepas96 and I am using "^6.7.1" with crashlytics:

    "@react-native-firebase/analytics": "^6.7.2",
    "@react-native-firebase/app": "^6.7.1",
    "@react-native-firebase/crashlytics": "^6.7.1",
    "@react-native-firebase/dynamic-links": "^6.7.1",
    "@react-native-firebase/in-app-messaging": "^6.7.1",
    "@react-native-firebase/messaging": "^6.7.1",

@afilp Try updating to latest v7.xx releases, they bring in the more up to date upstream firebase SDKs which might resolve things with no more effort than that

@mikehardy Thank you, I am a little confused with the documentation, I believe the crash is related to the messaging module but when I try to add crashlytics I am stuck with the message: "Add the SDK, then build and run your app"

Should we follow these instructions here?...
https://firebase.google.com/docs/crashlytics/get-started?platform=android&authuser=0#add-crashlytics

Or only these here?... (they are different and have less additions)
https://rnfirebase.io/crashlytics/android-setup

@afilp for react-native-firebase, follow rnfirebase.io exclusively unless it specifically points you to upstream docs. The module does a great deal of the necessary integration steps for you, made possible because of the react-native build+startup pathways hooks during compile/startup giving the module control and allowing it to do many of the integration steps

I had the same issue, I've fixed it by using:

implementation 'com.google.firebase:firebase-messaging:18.0.0'

which was:

implementation "com.google.firebase:firebase-messaging:17.5.0"

I've tested it with com.google.firebase:firebase-messaging:17.5.0, I can confirm that using 18.0.0 fixed the crash that happens only one time, at starting the app.

I am using "react-native-firebase": "~5.5.0" and implementation "com.google.firebase:firebase-core:16.0.8"

this solution works

Was this page helpful?
0 / 5 - 0 ratings