Keine statische Methode zzUr () in Firebase, wenn ich versuche, Analytics mit Benachrichtigungen zu verwenden

Ich fange an, Firebase Cloud Messaging zu verwenden.

Ich habe nur den Beispielcode des Handbuchs zur Verwendung von Notifications and Analytics. Wenn ich keine Analytics-Benachrichtigungen installiere, funktioniert dies einwandfrei. Wenn ich jedoch die Analytics in Gradle hinzufüge, wird dieser Fehler angezeigt, wenn ich versuche, eine Benachrichtigung zu senden:

java.lang.NoSuchMethodError: Keine statische Methode zzUr () Landroid / content / Intent; in der Klasse Lcom / google / firebase / iid / FirebaseInstanceIdInternalReceiver; oder seine Superklassen (die Deklaration von 'com.google.firebase.iid.FirebaseInstanceIdInternalReceiver' wird in /data/app/com.myapp.newapp-2/base.apk angezeigt) unter com.google.firebase.messaging.FirebaseMessagingService.zzz ( Unbekannte Quelle) unter com.google.firebase.iid.zzb.onStartCommand (Unbekannte Quelle) unter android.app.ActivityThread.handleServiceArgs (ActivityThread.java:3316) unter android.app.ActivityThread.access $ 2200 (ActivityThread.java:177) at android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1547) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:145) at android. app.ActivityThread.main (ActivityThread.java:5951) at java.lang.reflect.Method.invoke (Native Method) at java.lang.reflect.Method.invoke (Method.java:372) at com.android.internal. os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1195)

Ich habe in Gradle:

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

My MyFirebaseMessagingService:

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    // TODO(developer): Handle FCM messages here.
    // If the application is in the foreground handle both data and notification messages here.
    // Also if you intend on generating your own notifications as a result of a received FCM
    // message, here is where that should be initiated. See sendNotification method below.
    Log.d(TAG, "From: " + remoteMessage.getFrom());
    Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());

    sendNotification(remoteMessage.getNotification().getBody());
}

private void sendNotification(String messageBody) {
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setContentText(messageBody)
            .setAutoCancel(true)
            .setSound(defaultSoundUri)
            .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

Jede Hilfe wird geschätzt!

Antworten auf die Frage(12)

Ihre Antwort auf die Frage