猿问

未找到类“com.google.firebase.iid.FirebaseInstanceId”

我想通过 firebase 发送通知。当我发送通知时,我的应用程序崩溃,在 logcat 中显示这种类型的堆栈跟踪:


 java.lang.RuntimeException: Unable to instantiate receiver com.google.firebase.iid.FirebaseInstanceIdReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceIdReceiver" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.e_agriculture10-1.apk", zip file "/data/data/com.example.e_agriculture10/code_cache/secondary-dexes/com.example.e_agriculture10-1.apk.classes2.zip"],nativeLibraryDirectories=[/data/app-lib/com.example.e_agriculture10-1, /system/lib]]

    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2398)

    at android.app.ActivityThread.access$1700(ActivityThread.java:135)


  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.iid.FirebaseInstanceIdReceiver" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.e_agriculture10-1.apk", zip file "/data/data/com.example.e_agriculture10/code_cache/secondary-dexes/com.example.e_agriculture10-1.apk.classes2.zip"],nativeLibraryDirectories=[/data/app-lib/com.example.e_agriculture10-1, /system/lib]]

    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)

这是我的 FirebaseMessagingService.java 类


public class MyFirebaseMessagingService extends FirebaseMessagingService {


public  static int NOTIFICATION_ID = 1;

@Override

public void onMessageReceived(RemoteMessage remoteMessage) {


    generateNotification(remoteMessage.getNotification().getBody(),remoteMessage.getNotification().getTitle());


}



偶然的你
浏览 152回答 2
2回答

皈依舞

您可以删除此类“GettingDeviceTokenService”并覆盖“MyFirebaseMessagingService”类中的“onNewToken”方法。public void onNewToken(@NonNull String your_new_token) {super.onNewToken(s);}用你的新令牌做你想做的事

慕丝7291255

与 unownsp 的答案一起,如果您使用 proguard,这可能会有所帮助;将这些添加到您的 proguard 配置文件中:-dontwarn com.google.android.gms.** -keep class com.google.android.gms.** { *; } -keep class com.google.firebase.** { *; }
随时随地看视频慕课网APP

相关分类

Java
我要回答