我正在尝试运行,但总是出现此错误!
这是我的礼物:
implementation 'com.google.firebase:firebase-messaging:10.2.1'
implementation 'com.firebaseui:firebase-ui-database:4.2.1'
implementation "android.arch.core:runtime:1.1.1"
implementation "android.arch.core:common:1.1.1"
implementation 'com.google.android.gms:play-services:10.2.1'
//customDep
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
//noinspection GradleDynamicVersion
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
implementation 'com.github.mancj:MaterialSearchBar:0.7.6'
implementation 'com.jaredrummler:material-spinner:1.3.0'
implementation 'com.akexorcist:googledirectionlibrary:1.1.1'
implementation 'com.github.rey5137:material:1.2.5'
implementation 'com.github.d-max:spots-dialog:0.7@aar'
implementation 'io.paperdb:paperdb:2.6'
implementation 'com.stepstone.apprating:app-rating:2.3.0'
implementation 'com.github.andremion:counterfab:1.0.1'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
//facebook share
implementation 'com.facebook.android:facebook-share:[4,5)'
这是错误所在:
public class MyFirebaseMessaging extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage){
super.onMessageReceived(remoteMessage);
sendNotification(remoteMessage);
}
private void sendNotification(RemoteMessage remoteMessage) {
RemoteMessage.Notification notification = remoteMessage.getNotification();
Intent intent = new Intent(this,MainActivityServer.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT);
Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher_round)
.setContentTitle(notification.getTitle())
.setContentText(notification.getBody())
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
;
NotificationManager noti = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
noti.notify(0,builder.build());
}
}
该消息说它正好在“ remoteMessage”之后:
RemoteMessage.Notification notification = remoteMessage.getNotification();
我搜索了另一个类似的问题,他们回答了更新Google服务的gradle版本等问题,但在这种情况下不起作用。