Android 安卓5从软件包发布错误通知

Android 安卓5从软件包发布错误通知,android,notifications,Android,Notifications,我得到了以下stacktrace的许多异常。 对于Android

我得到了以下stacktrace的许多异常。 对于Android<5.0,它工作正常

我从我的LED通知应用程序LED闪烁器中获取错误。 我发布了一个没有图标的通知。我不知道如何重现它,但我收到了很多车祸报告

有什么建议吗

ANDROID_VERSION=5.0
PHONE_MODEL=Nexus 5
BUILD=BOARD=hammerhead
BOOTLOADER=HHZ12d
BRAND=google
CPU_ABI=armeabi-v7a
CPU_ABI2=armeabi
DEVICE=hammerhead
DISPLAY=LRX21O
FINGERPRINT=google/hammerhead/hammerhead:5.0/LRX21O/1570415:user/release-keys
HARDWARE=hammerhead
ID=LRX21O
MANUFACTURER=LGE
MODEL=Nexus 5
PRODUCT=hammerhead
RADIO=unknown
SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@2b1c12b
SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@20cc8988
SUPPORTED_ABIS=[Ljava.lang.String;@302e2f21
TAGS=release-keys
TYPE=user
UNKNOWN=unknown
USER=android-build
IS_DEBUGGABLE=false
TIME=1415320210000
VERSION.ACTIVE_CODENAMES=[Ljava.lang.String;@2a8c4f46
VERSION.CODENAME=REL
VERSION.INCREMENTAL=1570415
VERSION.RELEASE=5.0
VERSION.SDK=21
VERSION.RESOURCES_SDK_INT=21
VERSION.SDK_INT=21

USER_APP_START_DATE=2014-12-08T05:50:24.000+01:00
USER_CRASH_DATE=2014-12-08T07:32:05.000+01:00
CUSTOM_DATA=
STACK_TRACE=android.app.RemoteServiceException: Bad notification posted from package com.ledblinker: Couldn't create icon: StatusBarIcon(pkg=com.ledblinkeruser=0 id=0x0 level=0 visible=true num=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1441)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
一切正常,但有时会发生这种错误

以下是导致该问题的代码:

Notification resetNoti = new Notification(); 
resetNoti.ledARGB = Color.RED; 
resetNoti.ledOffMS = 0; 
resetNoti.ledOnMS = 1; 
resetNoti.flags = Notification.FLAG_SHOW_LIGHTS; 

尝试使用NotificationCompat.Builder类创建通知。它支持新的通知设计(包括用于可扩展通知的大文本),并支持旧的通知样式。 然后可以使用setLights设置通知颜色。您还需要一个通知对象,可以使用getNotification()从生成器对象获取该对象


希望这有帮助。

这是图标问题,棒棒糖不支持XML图标或向量内部通知。您必须使用PNG图标进行通知

NotificationCompat.Builder notify = new NotificationCompat.Builder(context);
notify.setLights(Color.argb(255, 255, 0, 0), 5000, 5000);
notify.setSmallIcon(R.drawable.ic_stat_kw);
notify.setContentTitle("Title");
notify.setContentText("Text");

Intent showIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, showIntent, 0); 
notify.setContentIntent(contentIntent);

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notify.getNotification());

另一个问题可能是图标资源文件不匹配,如果清单文件中的元数据包含有关推送通知图标的任何信息,那么它必须是notification builder中使用的同一文件
setSmallIcon()

没有建议我可以做什么?昨天我也遇到了这种情况,这是有史以来第一次。在带有安卓5.0的Nexus5上。奇怪的但不是从未安装的应用程序。阅读转储,我无法确定它指的是哪个应用。是的,我认为这又是一个固件错误。我使用这个代码已经两年了,从5.0开始就没有出现过。你能发布发布通知的代码吗。我看到id为0,这是需要显示的状态栏图标可绘制的id;resetNoti.ledARGB=Color.RED;resetNoti.ledOffMS=0;resetNoti.ledOnMS=1;resetNoti.flags=Notification.FLAG\u SHOW\u LIGHTS;我得到的错误与问题中的错误相同,但我已经在使用NotificationCompat.Builder,它无法解决问题。