今天开发一个Android应用程序时,我在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
我花了一段时间才弄清楚含义和该怎么做,所以我在下面添加了一个答案。
最佳答案
这是由 Pusher Beams Android SDK 生成的错误关于 Android 8.0 Oreo 中的错误的警告。参见 this article有关它的更多信息。另外,查看 this Stack Overflow Q&A .
如以上链接和 here in the documentation 中所述, 要解决该问题,请将以下 meta-data
添加到您的 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>
其中 ic_default_notification
是您自己创建的内容。要在 Android Studio 中制作它,请右键单击 drawable
文件夹并选择 New > Image Asset。对于图标类型,选择通知图标。
关于android - 错误 : adaptive icons with no fallback drawable for FCM notifications, 可能导致 Android Oreo 发生不可逆转的崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56483562/