React-native-fcm: Android App crash on recieve Notification

Created on 13 Oct 2016  路  3Comments  路  Source: evollu/react-native-fcm

Getting the following issue when notification received on android

java.lang.RuntimeException: Unable to instantiate service com.evollu.react.fcm.MessagingService: java.lang.ClassNotFoundException: Didn't find class "com.evollu.react.fcm.MessagingService" on path: DexPathList[[zip file "/data/app/com.vytaapp.worker-1/base.apk"],nativeLibraryDirectories=[/data/app/com.vytaapp.worker-1/lib/arm, /data/app/com.vytaapp.worker-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

Dependencies

dependencies {
compile(project(':react-native-fcm')){
   exclude group: 'com.google.android.gms'
        exclude group: 'com.google.firebase'
    }
    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms'
    }
    compile(project(':react-native-mauron85-background-geolocation')){
        exclude group: 'com.google.android.gms'
    }
    compile project(':react-native-twilio-ip-messaging')
    compile(project(':react-native-image-picker')){
        exclude group: 'com.google.android.gms'
    }
    compile project(':react-native-vector-icons')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.google.firebase:firebase-core:9.2.1'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    compile 'com.google.android.gms:play-services-maps:9.2.1'
    compile 'com.google.android.gms:play-services-gcm:9.2.1'
} 

Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.vytaapp.worker"
    android:versionCode="1"
    android:versionName="1.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <permission
        android:name="com.vytaapp.worker.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.vytaapp.worker.permission.C2D_MESSAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">
      <service android:name="com.evollu.react.fcm.MessagingService">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
      </service>
      <service android:name="com.evollu.react.fcm.InstanceIdService" android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
        </intent-filter>
      </service>
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
      <intent-filter>
           <action android:name="fcm.ACTION.HELLO" />
           <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
      </activity>
      <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
      <meta-data android:name="com.google.android.geo.API_KEY"
        android:value="#######################" />
    </application>
</manifest>

Main Application

package com.vytaapp.worker;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.evollu.react.fcm.FIRMessagingPackage;
import com.evollu.react.fcm.MessagingService;
import com.marianhello.react.BackgroundGeolocationPackage;
import com.airbnb.android.react.maps.MapsPackage;
import com.bradbumbalough.RCTTwilioIPMessaging.RCTTwilioIPMessagingPackage;
import com.facebook.react.ReactInstanceManager;
import com.imagepicker.ImagePickerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.vytaapp.worker.BuildConfig;

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

public class MainApplication extends Application implements ReactApplication {

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

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new FIRMessagingPackage(),
          new BackgroundGeolocationPackage(),
          new RCTTwilioIPMessagingPackage(),
          new ImagePickerPackage(),
          new MapsPackage()
      );
    }
  };

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

Most helpful comment

@AdrianZghibarta You need to add compile 'com.google.firebase:firebase-messaging:11.0.4' to your dependencies

All 3 comments

fixed, was not compiling firebase messagaging

@sf577 I have same issue, how did you solved this? How do you forced the firebase to compile?

@AdrianZghibarta You need to add compile 'com.google.firebase:firebase-messaging:11.0.4' to your dependencies

Was this page helpful?
0 / 5 - 0 ratings