Android 数组长度不正确,notification manager导致4.4上的手机崩溃

Android 数组长度不正确,notification manager导致4.4上的手机崩溃,android,android-4.4-kitkat,Android,Android 4.4 Kitkat,我将应用程序发布到BETA测试中,多个使用4.4设备的用户报告说,应用程序会导致整个手机崩溃,手机在应用程序发布后几乎会重新启动,尽管应用程序甚至没有这样的权限 我从测试人员那里得到的报告如下: java.lang.RuntimeException: bad array lengths at android.os.Parcel.readIntArray(Parcel.java:820) at android.app.INotificationManager$Stub$Proxy.enqueueN

我将应用程序发布到BETA测试中,多个使用4.4设备的用户报告说,应用程序会导致整个手机崩溃,手机在应用程序发布后几乎会重新启动,尽管应用程序甚至没有这样的权限

我从测试人员那里得到的报告如下:

java.lang.RuntimeException: bad array lengths
at android.os.Parcel.readIntArray(Parcel.java:820)
at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:348)
at android.app.NotificationManager.notify(NotificationManager.java:139)
at android.app.NotificationManager.notify(NotificationManager.java:112)
at als.wakeup.Awake_Alarm$MyLocationListener.onLocationChanged(Awake_Alarm.java:272)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:279)
at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:208)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:224)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
这在4.2、4.3上运行良好,但运行4.4的Galaxy Note 3和Galaxy S5似乎重新启动

原因可能是什么?它是否与应用程序相关,或者可能是新操作系统中的小故障

刚刚发现它在4.4版本的Xperia Z1上运行良好,没有崩溃。看来这是三星造成的,有什么提示吗

通知创建功能:

public Notification CreateNotification(double distance){


    Intent notificationIntentStop = new Intent(this.getApplicationContext(), StopService.class);
    PendingIntent contentIntentStop = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntentStop, 0);


    Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
    Shortcuts shorts = new Shortcuts(this);
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.logo)
            .setContentTitle("Localarm Running")
            .setLargeIcon(largeIcon);
    //mBuilder.addAction(R.drawable.ico, "Stop", contentIntentStop);
    if(distance > 0){
    mBuilder.setContentText(String.valueOf(roundTwoDecimals(shorts.ConvertUnits(distance))+" "+shorts.GetUnitNames(distance)+" to Alarm."));
    }
    else{
    mBuilder.setContentText(String.valueOf("You've reached your destination"));
    }
    mBuilder.setPriority(Notification.PRIORITY_MAX);
    Notification bui = mBuilder.build();

    bui.flags|= Notification.FLAG_NO_CLEAR;
        Intent notificationIntent = new Intent(this.getApplicationContext(), Intro.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this.getApplicationContext(), 0, notificationIntent, 0);
        bui.contentIntent = contentIntent;



    return bui;

}
调用它的方法是:onLocationChanged()


这是一个很好的例子。不幸的是,我认为你对此无能为力。

这有什么用吗?可能和我以前看到的类似,但困扰我的是,代码在所有其他手机和操作系统上都能完美运行,即使是除了索尼手机以外的同一操作系统,但在三星手机上它却崩溃了。当然是关于内存的问题。它看起来像是IPC实现中的一个bug。根据传入notify的id,将在NotificationManager中创建一个名为idOut的长度为1的数组。然后,这将通过IPC编组该数组来调用INotificationManager的实现(基本上是一个绑定器)。当地块解组同一阵列时,其大小与预期不匹配,因此引发异常。这是我从框架源代码中的最佳猜测,但我不知道它是否可以在allAlso上修复,所以只在Android 4.3上发生了此崩溃。
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);        
    notificationManager.notify(0, CreateNotification(dist_difference-alert_range));