Android 8.0接收通知后会手机崩溃,闪屏,恢复出厂设置的解决方法

最近用极光推送,发现有新的SDK,就试试用.我的手机是Nexus 6P,原生8.0,结果一更新,手机就不断闪屏,系统崩溃,说要恢复出厂设置了


Android 8.0接收通知后会手机崩溃,闪屏,恢复出厂设置的解决方法_第1张图片



幸亏重启前截停了.然后求助极光推送,可得到的答复不是SDK的问题,碰巧也有人碰到这问题,但他说他的解决方法是在drawable-xxxx各分辨率下加上jpush_notification_icon.png就可以避免了.可我试了不行.郁闷啊.一天重启几十遍.也跟着官方的SDK那样配置,一样还是不行.


主要出的系统log(不是app的log)在这里

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.systemui, PID: 10388
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:1001)
at android.graphics.Bitmap.createBitmap(Bitmap.java:968)
at android.graphics.Bitmap.createBitmap(Bitmap.java:918)
at android.graphics.Bitmap.createBitmap(Bitmap.java:879)
at android.graphics.drawable.AdaptiveIconDrawable.updateMaskBoundsInternal(AdaptiveIconDrawable.java:333)
at android.graphics.drawable.AdaptiveIconDrawable.updateLayerBounds(AdaptiveIconDrawable.java:295)
at android.graphics.drawable.AdaptiveIconDrawable.onStateChange(AdaptiveIconDrawable.java:782)
at android.graphics.drawable.Drawable.setState(Drawable.java:775)
at android.widget.ImageView.drawableStateChanged(ImageView.java:1305)
at android.view.View.refreshDrawableState(View.java:20012)
at android.view.View.dispatchAttachedToWindow(View.java:17409)
at android.view.ViewGroup.addViewInner(ViewGroup.java:4955)
at android.view.ViewGroup.addView(ViewGroup.java:4746)
at com.android.systemui.statusbar.phone.NotificationIconAreaController.updateIconsForLayout(NotificationIconAreaController.java:247)
at com.android.systemui.statusbar.phone.NotificationIconAreaController.updateNotificationIcons(NotificationIconAreaController.java:155)
at com.android.systemui.statusbar.phone.StatusBar.updateNotificationShade(StatusBar.java:1956)
at com.android.systemui.statusbar.phone.StatusBar.updateNotifications(StatusBar.java:2136)
at com.android.systemui.statusbar.phone.StatusBar.addNotificationViews(StatusBar.java:6702)
at com.android.systemui.statusbar.phone.StatusBar.addEntry(StatusBar.java:1627)
at com.android.systemui.statusbar.phone.StatusBar.onAsyncInflationFinished(StatusBar.java:1644)
at com.android.systemui.statusbar.notification.NotificationInflater$AsyncInflationTask.onAsyncInflationFinished(NotificationInflater.java:641)
at com.android.systemui.statusbar.notification.NotificationInflater.finishIfDone(NotificationInflater.java:460)
at com.android.systemui.statusbar.notification.NotificationInflater.-wrap0(Unknown Source:0)
at com.android.systemui.statusbar.notification.NotificationInflater$6.onViewApplied(NotificationInflater.java:343)
at android.widget.RemoteViews$AsyncApplyTask.onPostExecute(RemoteViews.java:3421)
at android.widget.RemoteViews$AsyncApplyTask.onPostExecute(RemoteViews.java:3401)
at android.os.AsyncTask.finish(AsyncTask.java:695)
at android.os.AsyncTask.-wrap1(Unknown Source:0)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)



后来终于有官方的技术人员解答了这个问题. 原来是系统的bug, 原贴在这里:

https://blog.pusher.com/upgrade-app-android-oreo-avoid-factory-reset/

如果你也有这个问题,你看看你新建的项目的资源文件目录里是不是有个mipmap-anydpi-v26的目录?里面有icon的xml文件? 处理的方法有三种,要么target SDK低于26或者不用这个icon,把这目录里面的icon的xml删掉.或者在manifest里加meta-data,


不过我自己试过加meta-data,还是不行.所以最简单的方法就是把那些icon的xml删了就是了.希望遇到这问题的各位也能顺利解决,我就困扰了两天,重启了4,50次了

你可能感兴趣的:(Android)