android status t,錯誤通知:無法展開RemoteViews for: StatusBarNotification。在Android上牛軋糖...

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

我使用OneSignal SDK來顯示通知。我是在OneSignalPushService.java中做的。

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:

這在我所有的設備上都很好用,但是:

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

我在Crashlytics上只收到了大量關於Android Nougat的設備的問題:

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.app。RemoteServiceException:來自package my的錯誤通知。無法擴展RemoteViews: StatusBarNotification(pkg=my)。package user=UserHandle {0} id=-1542711428標簽=null key=0|my。包零| 10184 | -1542711428 |:mso - fareast - font - family:宋體;mso - bidi - font - family: " times new roman "; mso - bidi - font - family: " times new roman "; mso - bidi - theme - font: minor - bidi ' > < spancom.android.internal.os.ZygoteInit MethodAndArgsCaller.run美元(ZygoteInit.java:1496)com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)

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

不幸的是,我無法在我的設備上重現這個問題,因為Android Nougat知道如何消除它。

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.

我注意到,當我發布新版本的應用程序時,這個問題的設備數量在一個星期內不斷增加。

這個問題也報告給谷歌和OneSignal SDK的開發人員。

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

我正在尋找任何解決辦法,任何可以幫助消除這個問題的想法或建議。

2 个解决方案

#1

8

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.

我認為這個崩潰發生是因為您的通知包含了PendingIntent包中的圖標的整數引用,這個整數在被發送給NotificationManager的時候被引用了。

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.

作為一種解決方案,您可以在應用程序更新后重新生成所有通知。

#2

0

Developers of OneSignal suggest to do next a work around:

OneSignal的開發人員建議接下來做一個工作:

Add following under the tag in a AndroidManifest.xml

在AndroidManifest.xml中,在

標簽下添加以下內容

...

These crashes disappeared when I did this temporary solution.

當我做這個臨時解決方案時,這些崩潰消失了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值