3

I have an Android app that is crashing due to an unhandled exeption, but only on one particular device (running Nougat). I believe they are the only one of my testers that is running Nougat. This is the exception:

Java.Lang.RuntimeException: Bad notification posted from package [my package name]: Couldn't cache contentViews: package=[my package name]

Here is the stack trace:

android.app.RemoteServiceException: Bad notification posted from package com.elephanigma.starmygrooves: Couldn't cache contentViews: package=com.elephanigma.starmygrooves
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6247)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Xamarin caused by: Java.Lang.RuntimeException: Bad notification posted from package com.elephanigma.starmygrooves: Couldn't cache contentViews: package=com.elephanigma.starmygrooves
  --- End of managed Java.Lang.RuntimeException stack trace ---
android.app.RemoteServiceException: Bad notification posted from package com.elephanigma.starmygrooves: Couldn't cache contentViews: package=com.elephanigma.starmygrooves
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6247)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)

The stack trace does not show any of my own code. My app does not create any notifications itself, but it does use an open source package (Xamarin Media Manager) that does. The stack trace does not show any of that package's code either.

So, I'm not sure where to look. I have tried searching for this exception, and although I get a couple of hits for "Bad notification posted", none of them seem to address my issue. I do not get ANY hits for "Couldn't cache contentViews".

If it helps, here is the code (as best I can tell) from the package that creates the notification: (note this is c# code, because it's using Xamarin/Mono)

    /// <summary>
    /// When we start on the foreground we will present a notification to the user
    /// When they press the notification it will take them to the main page so they can control the music
    /// </summary>
    public void StartNotification(IMediaFile mediaFile, bool mediaIsPlaying, bool canBeRemoved)
    {
        var icon = (_appliactionContext.Resources?.GetIdentifier("xam_mediamanager_notify_ic", "drawable", _appliactionContext?.PackageName)).GetValueOrDefault(0);

        _notificationStyle.SetMediaSession(_sessionToken);
        _notificationStyle.SetCancelButtonIntent(_pendingCancelIntent);

        _builder = new NotificationCompat.Builder(_appliactionContext)
        {
            MStyle = _notificationStyle
        };
        _builder.SetSmallIcon(icon != 0 ? icon : _appliactionContext.ApplicationInfo.Icon);
        _builder.SetContentIntent(_pendingIntent);
        _builder.SetOngoing(mediaIsPlaying);
        _builder.SetVisibility(1);

        SetMetadata(mediaFile);
        AddActionButtons(mediaIsPlaying);
        if (_builder.MActions.Count >= 3)
            ((NotificationCompat.MediaStyle)(_builder.MStyle)).SetShowActionsInCompactView(0, 1, 2);

        NotificationManagerCompat.From(_appliactionContext)
            .Notify(MediaServiceBase.NotificationId, _builder.Build());
    }
Şafak Gezer
  • 3,928
  • 3
  • 47
  • 49
JoeMjr2
  • 3,804
  • 4
  • 34
  • 62

0 Answers0