Ad

Error: Adaptive Icons With No Fallback Drawable For FCM Notifications, Can Cause Irreversible Crash On Android Oreo

When developing an Android app today, I got the following error message in the logcat:

You are targeting Android Oreo and using adaptive icons without having a fallback drawable set for FCM notifications. This can cause a irreversible crash on devices using Oreo. To learn more about this issue check: https://issuetracker.google.com/issues/68716460

It took me a while to track down the meaning and what to do, so I am adding an answer below.

Ad

Answer

This is an error generated by the Pusher Beams Android SDK warning about a bug in Android 8.0 Oreo. See this article for more information about it. Also, check out this Stack Overflow Q&A.

As mentioned in the above links and here in the documentation, to solve the problem, add the following meta-data to your AndroidManifest:

<manifest ...>
    <application...>

        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_default_notification" />
       <meta-data
            android:name="com.google.firebase.messaging.default_notification_color"
            android:resource="@color/colorAccent" />

    </application>
</manifest>

where ic_default_notification is something you create yourself. To make it in Android Studio, right click the drawable folder and choose New > Image Asset. For the Icon Type choose Notification Icons.

enter image description here

Ad
source: stackoverflow.com
Ad