We have a lot of crashes specific to Xiaomi phones on Android 6 and 7:
Fatal Exception: android.app.RemoteServiceException: Bad notification posted from package x.y.z: Couldn't create icon: StatusBarIcon(icon=Icon(typ=RESOURCE pkg=x.y.z id=0x7f0200ad) visible user=0 )
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1715)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6358)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
I've found a lot of similar crash reports and articles on the net. Here is a few:
https://medium.com/@Miqubel/the-story-of-a-hard-to-fix-bug-ac6ed819cb49
But the difference is that we have these problems only on Xiaomi phones (Android 6 and 7) and probably not during updates as the same users have the crash several times in the same release version.
Interestingly I couldn't find anything on the net on this specific case and we don't have any Xiaomi phones around.
I set the notification something like this:
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel notificationChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, NOTIFICATION_CHANNEL_NAME, importance);
notificationChannel.enableLights(true);
notificationManager.createNotificationChannel(notificationChannel);
}
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_notification)
.setPriority(NotificationCompat.PRIORITY_MAX)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
.setContentText(body == null ? "" : body)
.setAutoCancel(true)
.setContentIntent(PendingIntent.getActivity(
context,
0,
pendingIntent,
PendingIntent.FLAG_UPDATE_CURRENT
));
We also have Facebook notifications, which have to be set in a similar manner, but on a different Notification class. I don't know if it's relevant. Did anybody ran into this or have any recommendation how to fix this apart from wrapping the setSmallIcon and/or the setLargeIcon methods in a Manufacturer and Android version check?
EDIT: I couldn't find a solution, but here are a few new thoughts:
-
We released a new version, but excluding Xiaomi users from notification didn't help! Now I think the problem is caused by the custom code in ActivityThread.java. MIUI probably fires a notification from here on some event. There are a few dozen events in stock Android here, but none of them fires a notification. But something is wrong with our icons, so they crash.
-
But what is wrong with our icons? We have an ic_notification, which is probably not used for this. On the other hand, ic_launcher is a mipmap. Is it maybe this? But I couldn't find any problems regarding Xiaomi and mipmaps.
-
The crash report always mentions the same resource id across several app versions: 0x7f0200ad. Is this special for some reason? How can I reverse engineer our app to get the resource name for this?
EDIT2:
- I reverse engineered the app with apktool, but the resource id is not in public.xml, which seems to be the equivalent of R.java. Our ic_notification and ic_launcher is in the list with a different id. So is this a system resource what MIUI cannot find?
from How to fix Xiaomi specific RemoteServiceException with notification icon?
No comments:
Post a Comment