私はアンドロイドアプリでfirebaseを使用してプッシュ通知を送信しています。メッセージを送信してアプリが終了すると、通知が受信され、意図は機能し、すべて正常です。アプリが開いていて、私がメッセージを送信するときしかし、それはgetColor()
方法から、このエラーでクラッシュ:fcmが送信されてアプリが開いているときにAndroidアプリがクラッシュする
Exception java.lang.NoSuchMethodError: No virtual method getColor(I)I in class Lcom/kinectafrica/android/service/FirebaseMessagingService; or its super classes (declaration of 'com.kinectafrica.android.service.FirebaseMessagingService' appears in /data/app/com.kinectafrica.android-1/base.apk)
com.kinectafrica.android.service.FirebaseMessagingService.sendNotification (FirebaseMessagingService.java:45)
com.kinectafrica.android.service.FirebaseMessagingService.onMessageReceived (FirebaseMessagingService.java:33)
com.google.firebase.messaging.FirebaseMessagingService.zzo()
com.google.firebase.messaging.FirebaseMessagingService.zzn()
com.google.firebase.messaging.FirebaseMessagingService.zzm()
com.google.firebase.iid.zzb$2.run()
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:587)
java.lang.Thread.run (Thread.java:818)
これは私のFirebaseMessagingService
クラスです。これを引き起こしている可能性が何
package com.kinectafrica.android.service;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.firebase.messaging.RemoteMessage;
import com.kinectafrica.android.R;
import com.kinectafrica.android.activity.SplashScreenActivity;
/**
* Made by acefalobi on 5/16/2017.
*/
public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
int notifyId = 0;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d("Service", "From: " + remoteMessage.getFrom());
if (remoteMessage.getData().size() > 0) {
Log.d("Service", "Message data payload: " + remoteMessage.getData());
}
if (remoteMessage.getNotification() != null) {
Log.d("Service", "Message notification: " + remoteMessage.getNotification().getBody());
}
sendNotification(remoteMessage.getData().get("message"));
}
private void sendNotification(String message) {
Intent intent = new Intent(this, SplashScreenActivity.class);
intent.putExtra("isNotify", true);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_notify)
.setColor(getColor(R.color.colorAccent))
.setContentTitle("Kinect")
.setWhen(System.currentTimeMillis())
.setContentText(message)
.setAutoCancel(true)
.setSound(uri)
.setContentIntent(pendingIntent)
.setStyle(new NotificationCompat.BigTextStyle().bigText(message))
.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(notifyId, builder.build());
notifyId++;
}
}
任意のアイデア?ありがとう。
ログクラッシュのログcat –