今天,我注意到我的应用程序停止在Oreo之前的设备(API级别低于26)上从OneSignal接收通知。在尝试调试时,我注意到应该在收到通知时抛出此异常。
Rejecting re-init on previously-failed class java.lang.Class<com.onesignal.JobIntentService$JobServiceEngineImpl>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/app/job/JobServiceEngine;
at android.content.Intent com.onesignal.NotificationExtenderService.getIntent(android.content.Context) (NotificationExtenderService.java:212)
at boolean com.onesignal.NotificationBundleProcessor.startExtenderService(android.content.Context, android.os.Bundle, com.onesignal.NotificationBundleProcessor$ProcessedBundleResult) (NotificationBundleProcessor.java:456)
at com.onesignal.NotificationBundleProcessor$ProcessedBundleResult com.onesignal.NotificationBundleProcessor.processBundleFromReceiver(android.content.Context, android.os.Bundle) (NotificationBundleProcessor.java:430)
at com.onesignal.NotificationBundleProcessor$ProcessedBundleResult com.onesignal.GcmBroadcastReceiver.processOrderBroadcast(android.content.Context, android.content.Intent, android.os.Bundle) (GcmBroadcastReceiver.java:125)
at void com.onesignal.GcmBroadcastReceiver.onReceive(android.content.Context, android.content.Intent) (GcmBroadcastReceiver.java:72)
at void android.app.ActivityThread.handleReceiver(android.app.ActivityThread$ReceiverData) (ActivityThread.java:3032)
at void android.app.ActivityThread.-wrap18(android.app.ActivityThread, android.app.ActivityThread$ReceiverData) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1557)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
at void android.os.Looper.loop() (Looper.java:154)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6123)
at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:867)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:757)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.app.job.JobServiceEngine" on path: DexPathList[[ ... ],nativeLibraryDirectories=[ ... ]
at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
at android.content.Intent com.onesignal.NotificationExtenderService.getIntent(android.content.Context) (NotificationExtenderService.java:212)
at boolean com.onesignal.NotificationBundleProcessor.startExtenderService(android.content.Context, android.os.Bundle, com.onesignal.NotificationBundleProcessor$ProcessedBundleResult) (NotificationBundleProcessor.java:456)
at com.onesignal.NotificationBundleProcessor$ProcessedBundleResult com.onesignal.NotificationBundleProcessor.processBundleFromReceiver(android.content.Context, android.os.Bundle) (NotificationBundleProcessor.java:430)
at com.onesignal.NotificationBundleProcessor$ProcessedBundleResult com.onesignal.GcmBroadcastReceiver.processOrderBroadcast(android.content.Context, android.content.Intent, android.os.Bundle) (GcmBroadcastReceiver.java:125)
at void com.onesignal.GcmBroadcastReceiver.onReceive(android.content.Context, android.content.Intent) (GcmBroadcastReceiver.java:72)
at void android.app.ActivityThread.handleReceiver(android.app.ActivityThread$ReceiverData) (ActivityThread.java:3032)
at void android.app.ActivityThread.-wrap18(android.app.ActivityThread, android.app.ActivityThread$ReceiverData) (ActivityThread.java:-1)
at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1557)
at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
at void android.os.Looper.loop() (Looper.java:154)
at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6123)
at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:867)
at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:757)
有时不会引发异常(特别是在使用仿真器时),但是通知仍然不会显示
我正在使用带有自定义NotificationExtenderService的OneSignal 3.10.6 gradle实现。 ( 有什么可能的原因的想法吗?最近,我更改了项目proguard规则,但即使禁用proguard,该错误仍然存在。
修改 看来问题出在 NotificationExtenderService 中。当我禁用CustomNotificationExtenderService并添加了NotificationReceivedHandler时,通知开始到达,但是,我无法切换到NotificationReceivedHandler,因为我仍然需要能够选择要向用户显示的通知以及显示的内容作为警报或仅仅是通知。