1

Following this tutorial I try to integrate the Firebase SDK in an Android application (in fact it is a ReactNative-Application but on this level it doesn't matter) but run into several compiler-errors when it comes to use the classes from firebase-messaging.

The compiler states that only versions 9.0.0 are compatible with each other. But these versions can't be used with the client side code that was listed in the tutorial.

Some people (A, B) write, that firebase-messaging must be compiled in V 9.2.1 or 10.0.1, but Android Studio complaints then, that these versions are not compatible to google-play-services 10.0.1. The same happens, when i increase google-play-services to 11.0.1 (there is no 10.0 or 9.2 available):

Found com.google.firebase:firebase-core:9.2.1, but version 9.0.0 is needed for the google-services plugin.
Found com.google.firebase:firebase-messaging:9.2.1, but version 9.0.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of 
the google-services plugin (information about the latest version is available at 
https://bintray.com/android/android-tools/com.google.gms.google-services/) 
or updating the version of com.google.android.gms to 9.0.0.

These are the compiler errors:

1. Cannot access AbstractSafeParcelable

error: cannot access AbstractSafeParcelable i.putExtra("data", remoteMessage);

package com.cooblr.notification;

import android.content.Intent;
import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Intent i = new Intent("Message");
        i.putExtra("data", remoteMessage);
        sendOrderedBroadcast(i, null);
    }
}

2. AbstractSafeParcelable not found

class file for com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable not found

and so on...

Gradle:

./android/build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath 'com.google.gms:google-services:3.1.0'

./android/app/build.gradle:

compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-messaging:9.2.1'
KENdi
  • 7,576
  • 2
  • 16
  • 31
itinance
  • 11,711
  • 7
  • 58
  • 98
  • I use classpath 'com.google.gms:google-services:3.0.0' in project/build.gradle and compile 'com.google.firebase:firebase-messaging:9.6.0, compile 'com.google.android.gms:play-services-maps:9.6.0', compile 'com.google.firebase:firebase-database:9.6.0' – eurosecom Jul 11 '17 at 13:03
  • Here https://firebase.google.com/docs/android/setup are Available libraries for Firebase and classpath 'com.google.gms:google-services:3.1.0' – eurosecom Jul 11 '17 at 13:05
  • @eurosecom thx, but this results in: Found com.google.android.gms:play-services:9.6.0, but version 9.0.0 is needed for the google-services plugin. Found com.google.android.gms:play-services-maps:9.6.0, but version 9.0.0 is needed for the google-services plugin. :app:processDebugGoogleServices FAILED – itinance Jul 11 '17 at 13:22
  • All of your Play Services and Firebase dependencies should be at the exact same version, all of the time. The latest version at the time of this writing is 11.0.2. The latest version of the google-services plugin is 3.1.0. – Doug Stevenson Jul 11 '17 at 14:49

1 Answers1

1

You have to add following in your app level gradle

dependencies {
 compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'

and in project level gradle

 dependencies {
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

I am using it in my current application so its working.goodluck

Avinash
  • 264
  • 5
  • 15
  • Additional note: PLEASE NEVER DEPEND ON "com.google.android.gms:play-services" as that would add EVERY google mobile library to your project. You should always depend to "com.google.android.gms:play-services-SPECIFIC-LIBRARY" or 'com.google.firebase:firebase-LIBRARY' – Diego Giorgini Jul 15 '17 at 13:25