错误通知:无法展开RemoteViews:StatusBarNotification。在Android Nougat上 [英] Bad Notification: Couldn't expand RemoteViews for: StatusBarNotification. on Android Nougat

查看:338
本文介绍了错误通知:无法展开RemoteViews:StatusBarNotification。在Android Nougat上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 OneSignal SDK 来显示通知。
我在 OneSignalPushService.java

I use OneSignal SDK to show notifications. I do it in OneSignalPushService.java.

OneSignalPushService.java:

public class OneSignalPushService extends NotificationExtenderService {

    @Override
    protected boolean onNotificationProcessing(OSNotificationReceivedResult notification) {

        if (!TinyDbWrap.getInstance().isPushEnabled()) {
            KLog.d(this.getClass().getSimpleName(), "Notification will not displayed");
            return true;
        }

        OverrideSettings overrideSettings = new OverrideSettings();
        overrideSettings.extender = new NotificationCompat.Extender() {
            @Override
            public NotificationCompat.Builder extend(NotificationCompat.Builder notificationBuilder) {
                notificationBuilder.setDefaults(0);
                notificationBuilder.setContentTitle(getApplicationContext().getResources().getString(R.string.app_name));

                boolean is_in_silent_mode = false; /*or true by user's settings in app*/
                /*TinyDbWrap.getInstance()... - it stores user's settings*/
                KLog.d(OneSignalPushService.class.getSimpleName(), "Notification isSoundPushEnabled: " + TinyDbWrap.getInstance().isSoundPushEnabled());
                if (!is_in_silent_mode && TinyDbWrap.getInstance().isSoundPushEnabled()) {
                    notificationBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
                } else {
                    notificationBuilder.setSound(null);
                }

                KLog.d(OneSignalPushService.class.getSimpleName(), "Notification isVibrationPushEnabled: " + TinyDbWrap.getInstance().isVibrationPushEnabled());
                if (!is_in_silent_mode && TinyDbWrap.getInstance().isVibrationPushEnabled()) {
                    notificationBuilder.setVibrate(new long[]{0, 100, 200, 300, 400});
                } else {
                    notificationBuilder.setVibrate(new long[]{0});
                }

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    notificationBuilder.setColor(ContextCompat.getColor(getApplicationContext(), R.color.bg_first_item_white_scheme));
                }
                notificationBuilder.setLights(ContextCompat.getColor(getApplicationContext(), R.color.time_white_sheme), 500, 500);
                return notificationBuilder;
            }
        };

        OSNotificationDisplayedResult result = displayNotification(overrideSettings);
        if (result != null) {
            KLog.d(OneSignalPushService.class.getSimpleName(), "Notification displayed with id: " + result.androidNotificationId);
        }

        return true;
    }

}

这适用于我的所有设备但是:

This works well on all my devices but:

我只在使用Android Nougat的设备上收到大量关于Crashlytics的问题:

I'm receiving a big number of this issue on Crashlytics only on devices with Android Nougat:


致命异常:android.app.RemoteServiceException:从包my.package发布的错误通知

无法展开RemoteViews:
StatusBarNotification(pkg = my .package user = UserHandle {0} id = -1542711428 tag = null key = 0 | my.package | -1542711428 | null | 10184:
通知(pri = 0 contentView = null vibrate = null sound = null defaults = 0x0标志= 0x19颜色= 0xff56a0d3 vis = PUBLIC semFlags = 0x0
semPriority = 0))
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1813)
在android。 os.Handler.dispatchMessage(Handler.java:102)
在android.os.Looper.loop(Looper.java:154)
在android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com .android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package my.package: Couldn't expand RemoteViews for: StatusBarNotification(pkg=my.package user=UserHandle{0} id=-1542711428 tag=null key=0|my.package|-1542711428|null|10184: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x19 color=0xff56a0d3 vis=PUBLIC semFlags=0x0 semPriority=0)) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1813) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

不幸的是,我无法重现此问题我的设备用 Android Nougat 来了解我如何消除它。

Unfortunately, I can't reproduce this issue on my devices with Android Nougat to understand how I can eliminate it.

我试图更改图标资源,如图标通知,清理项目以遵循此建议

I tried to change graphics resources such as icons of notification, to clean project in order to follow this advice.

我注意到这个问题的设备数量增加了一个星期,当我发布新版本的应用程序后,这些数字减少到零。

I noticed that number of devices with this issue increase for a week when I release a new version of the app later these numbers decrease to zero.

此问题也< a href =https://issuetracker.google.com/issues/67397632\"rel =noreferrer>向Google报告和 OneSignal的开发者 SDK

This issue also reported to Google and developers of OneSignal SDK.

我正在寻找任何解决方法,任何想法或建议可以帮助消除这个问题。

I'm looking for any workarounds, any ideas or suggestions which can help eliminate this issue.

推荐答案

我认为这次崩溃是因为你的通知包含对图标中的图标的整数引用PendingIntent包,稍后在发布到NotificationManager时引用该整数。

I think this crash happens because your notification include the integer reference to the icon in the PendingIntent bundle, and that integer was later being referenced while being posted to the NotificationManager.

在获取整数引用和挂起的意图之间,应用程序已更新,所有可绘制的引用都已更改。用于引用正确drawable的整数现在引用了不正确的drawable或者根本没有引用(根本没有 - 导致此崩溃)

In between getting the integer reference and the pending intent going off, the app was updated and all of the drawable references changed. The integer that used to reference the correct drawable now referenced either the incorrect drawable or none at all (none at all - causing this crash)

这可以通过

This is evidenced by


我注意到这个问题的设备数量增加了一周
当我发布新版本的应用程序后,这些数字会减少
为零。

I noticed that number of devices with this issue increase for a week when I release a new version of the app later these numbers decrease to zero.

作为一种解决方案,您可以在应用程序更新后重建所有通知。

As a solution you can rebuild all notifications after the application has been updated.

这篇关于错误通知:无法展开RemoteViews:StatusBarNotification。在Android Nougat上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆