Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase messaging NoSuchMethodError.zzUr exception

i am trying to integrate FCM to android project as it's written in Firebase documentation.

My app's gradle:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
...
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-config:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.firebase:firebase-crash:9.2.0'
compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.google.android.gms:play-services-games:9.2.0'
}

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

Manifest.xml:

<service
    android:name=".MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>

And MyFirebaseMesagingService:

public class MyFirebaseMessagingService extends FirebaseMessagingService {

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.i("info", "From: " + remoteMessage.getFrom());
    Log.i("info", "Notification Message Body: " + remoteMessage.getNotification().getBody());
}

}

But when i send push, what i get is:

java.lang.NoSuchMethodError: com.google.firebase.iid.FirebaseInstanceIdInternalReceiver.zzUr
                                                      at com.google.firebase.messaging.FirebaseMessagingService.zzz(Unknown Source)
                                                      at com.google.firebase.iid.zzb.onStartCommand(Unknown Source)
                                                      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2805)
                                                      at android.app.ActivityThread.access$1900(ActivityThread.java:156)
                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
                                                      at android.os.Handler.dispatchMessage(Handler.java:99)
                                                      at android.os.Looper.loop(Looper.java:153)
                                                      at android.app.ActivityThread.main(ActivityThread.java:5299)
                                                      at java.lang.reflect.Method.invokeNative(Native Method)
                                                      at java.lang.reflect.Method.invoke(Method.java:511)
                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
                                                      at dalvik.system.NativeStart.main(Native Method)

Cannot google it. Have anyone faced with it?

like image 739
YTerle Avatar asked Jul 05 '16 10:07

YTerle


4 Answers

Try running all services with the same version. In this case, change:

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

to

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

and check if the same issue happens.

like image 190
sunil sunny Avatar answered Nov 17 '22 20:11

sunil sunny


Change the versions of firebase1 It works to me!

The versions must be the same:

compile 'com.google.firebase:firebase-analytics:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.firebase:firebase-core:9.2.0'
like image 42
Douglas Avatar answered Nov 17 '22 21:11

Douglas


I have face same problem and resolve this issue by configuring proguard rules properly.

What I did here under as below:

First I have excluded google classes from obfuscating like this in proguard-rules.pro:

-keep public class com.google.** {*;}

Second I have enabled this minifyEnabled in build.gradle like this:

    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.e2e.quiz"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }

    dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.google.android.gms:play-services-gcm:9.2.1'
compile 'com.google.android.gms:play-services-analytics:9.2.1'
compile 'com.google.android.gms:play-services-ads:9.2.1'
compile project(':ast-dst')

}

like image 3
Geek Avatar answered Nov 17 '22 22:11

Geek


keep the same version of the firebase-core library and firebase-messaging library by Changing the firebase-messaging library version in build gradle

from:

compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.0.2

to:

compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
like image 1
Frank Odoom Avatar answered Nov 17 '22 22:11

Frank Odoom