How to upgrade your app to Android Oreo and avoid a factory reset

Android Oreo has adaptive icons that can’t be inflated by the system UI into a notification. System UI crashes when a notification is received without a specified icon. Repeatedly. Until you uninstall the app programmatically. Most people might need a factory reset.

See the image below. It’s important to force the default notification icon using the metadata tags in AndroidManifest.xml.

Intrigued? Read on.

The problem with Android Oreo

We discovered an intriguing, somewhat scary issue with the latest version of Android – 8.0 aka Oreo. It can, and will, cause your system to go into a nasty crash loop involving the system. The culprit? A push notification.

The nasty bit about it is that you might not know about it until your app has already been installed by your users, and you didn’t try sending a push notification to it. After all, who tests for Android Oreo that 0.3% of people have installed, right? :trollface: (as of November 2017)
Here you go, reproduced in a friendly emulator near you:

The loop of Death

Now if this happens in an emulator, you’re probably a developer, and just a single adb uninstall from solving the problem.

But what if it happens to your user? The last thing you want is having to tell your users to factory reset the device. It happened to cause a major uproar with at least one application – Swipe for Facebook. Various publications have published stories about it:

We discovered this problem when building the new Pusher Push Notifications SDK. After some digging, we found a way around it and learned a bunch of stuff about adaptive notifications in the process.

Steps to reproduce

  1. Create a new Android Studio project, an app is fine. Ensure it the target SDK is 26 or higher.
  2. Include Firebase, add the generated google-services.json , and the firebase-messaging dependency. The steps to follow are described here:
  3. Start an emulator with Android Oreo 8.0 (SDK 26). I used a Pixel Emulator. Install the application, and background once it’s running.
  4. Send a notification to the phone; you can use the Firebase console to compose it:
Compose any notification
  1. Observe the crash and the crash log. Note that you’ll need to select “no filters” if viewing the logs in Android Studio, as it’s caused by the System UI trying to inflate the view.

The crash log is below:

    E/AndroidRuntime: FATAL EXCEPTION: main
                      Process:, PID: 4555
                      java.lang.IllegalArgumentException: width and height must be > 0
                          at android.widget.ImageView.drawableStateChanged(
                          at android.view.View.refreshDrawableState(
                          at android.view.View.dispatchAttachedToWindow(
                          at android.view.ViewGroup.addViewInner(
                          at android.view.ViewGroup.addView(
                          at android.os.Handler.handleCallback(
                          at android.os.Handler.dispatchMessage(
                          at android.os.Looper.loop(
                          at java.lang.reflect.Method.invoke(Native Method)

Digging deeper…

We can see from the logs, that the crash is caused by view inflation when a notification is being created, and one specifically related to the new Adaptive Icons that were introduced in Oreo.

Adaptive icons are a new thing introduced in Android Oreo. They can change the icon shape, based on the device’s own preferences. That means icons will look differently on Samsung, Pixel, OnePlus, and other devices by different manufacturers, yet still in the line with the rest of the UI. They also support visual effects, presumably so Michael Bay can make them explode. For more information about them, feel free to read the official guide on

To create an adaptive effect, we can’t rely on just resources in mipmaps anymore. The adaptive icons live in mipmap-anydpi-v26 folder and are defined in XML, as you can see from the image below. On devices running SDK 25 and lower the icons will just be taken from the corresponding mipmap-xdpi folder.

Resource hierarchy, as generated by Android Studio 3.0

SDK 26 and above use the following drawable element, defined by the adaptive-icon node:


    <adaptive-icon xmlns:android="">
        <background android:drawable="@drawable/ic_launcher_background" />
        <foreground android:drawable="@drawable/ic_launcher_foreground" />

Solving the problem

The easiest thing to do would be to target SDK 25 or avoid using Adaptive Icons for now, until a fix is issued by Google.

A better way would be to add metadata tags to your Android Manifest, that specify a new default drawable for notifications created by FCM. That drawable must not be an adaptive icon.

In your Application tags in Manifest you could put something like this:

        android:resource="@drawable/your_non_adaptive_drawable" />

Lastly, you could ensure that all the notifications are sent with the icon payload that specifies the desired drawable (must be non-adaptive).
Note that you cannot do this from the Firebase Notifications console. You can either use the API directly or a third-party notifications provider such as Pusher.

How we are helping our customers avoid this problem

We wrote this blog post for starters to raise awareness. ?

We are adding a validation function to our new SDK that will clearly alert our app developers to this problem when the application starts.

    internal fun validateApplicationIcon(context: Context) {
      if (targetSdkIsBelowOreo(context)) {
      if (canCreateIconDrawable(context)) {
      if (hasDefaultFCMIconInMetadata(context)) {

      throw IllegalStateException(
        "You are targetting Android Oreo and using adaptive icons without having a fallback drawable set for FCM notifications. \n This can cause an irreversible crash on devices using Oreo. \n " +
          "To learn more about this issue check:")

The function checks for 3 things:
First, it checks whether the target SDK used is Android Oreo or newer, then whether the launcher icon is adaptive, and lastly if default drawable metadata is set in the Manifest.
If any of these things are true, it’s all good – otherwise, we throw an IllegalStateException with a message explaining how to avoid the potential issue.
You can find the entire validation logic in a gist we published on Github.

Google already issued a fix for the crash in Android 8.1, which is currently available on the Beta channel.
Some existing Pixel devices will probably still be on Oreo for the time being, however. We believe that they will also put some preventive measures in the Firebase SDK, likely defaulting to a fallback bitmap when Firebase Notifications are added, possibly injected directly to the Manifest via their Gradle plugin.

Until then, you have Pusher. Happy coding! ?

Ready to begin?

Start building your realtime experience today.

From in-app chat to realtime graphs and location tracking, you can rely on Pusher to scale to million of users and trillions of messages