我想通过 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;@Overridepublic void onMessageReceived(RemoteMessage remoteMessage) { generateNotification(remoteMessage.getNotification().getBody(),remoteMessage.getNotification().getTitle());}
2 回答
皈依舞
TA贡献1851条经验 获得超3个赞
您可以删除此类“GettingDeviceTokenService”并覆盖“MyFirebaseMessagingService”类中的“onNewToken”方法。
public void onNewToken(@NonNull String your_new_token) {super.onNewToken(s);}
用你的新令牌做你想做的事
慕丝7291255
TA贡献1859条经验 获得超6个赞
与 unownsp 的答案一起,如果您使用 proguard,这可能会有所帮助;将这些添加到您的 proguard 配置文件中:
-dontwarn com.google.android.gms.** -keep class com.google.android.gms.** { *; } -keep class com.google.firebase.** { *; }
添加回答
举报
0/150
提交
取消