Notification icon on Android shown as a white square

2,137

Solution 1

I think you generated the icons of wrong size. I re-generated them using the android asset studio and seems to be working at my end. You can download then using this link:

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=text&source.text.text=capenergy&source.space.trim=1&source.space.pad=0&name=ic_stat_capenergy

Solution 2

Background of notification icon should be transparent From Android 5.0 Lollipop Notification icons must be entirely white.

Solution 3

I think you should checkout this. I also hat a lot of problems with that so I saved that answer to my bookmarks ;)

Share:
2,137
mvasco
Author by

mvasco

Learning mobile apps development at a late age...

Updated on January 01, 2023

Comments

  • mvasco
    mvasco over 1 year

    I am using Firebase Cloud Messaging with my Flutter app.

    I am sending Push Notifications to my app using the Firebase Console.

    My issue is regarding the notification icon on Android.

    I have created an icon with Android Asset Studio, as follows:

    enter image description here

    Then I have included the downloaded assets into their respective folder at android/app/main/res/mipmap.

    On Manifest I have included the needed meta-data code:

    <meta-data
        android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@mipmap/ic_stat_logopush" />
    

    But when sending a notification, a white square is shown.

    enter image description here

    enter image description here

    What am I missing or doing wrong?

    Edit:

    This my current file:

    enter image description here

    • Milan Tejani
      Milan Tejani over 2 years
      Does this happen on every device or some devices?
    • CommonsWare
      CommonsWare over 2 years
      Try putting them in drawable directories, not mimpap directories. AFAIK, mimpap is only for launcher icons.
    • mvasco
      mvasco over 2 years
      @CommonsWare, let me try your proposal
    • Alexander Hoffmann
      Alexander Hoffmann over 2 years
      Is the background actually transparent? Android will only use the outlines of your icon.
    • Nitish
      Nitish over 2 years
      Your image doesn't seems to be completely transparent , you need to make background transparent.
    • mvasco
      mvasco over 2 years
      @NitishChaudhary, I have created the image with a transparent background. How can I be sure that it is really transparent?
    • Nitish
      Nitish over 2 years
      What's the dimension of the image you are using , above attach image has a dimension of 512x512 which too large for notification. Can you reduce it to 24x24 , 36x36 and 48x48 for hdpi , xhdp and xxhdpi.
    • Nitish
      Nitish over 2 years
      To check transparency you can use online editor - photopea.com
    • mvasco
      mvasco over 2 years
      @NitishChaudhary, it is transparent now, but the issue is there. I have downloaded the assets from Android Asset Studio with their end size depending on their respective drawable folder
  • snachmsm
    snachmsm over 2 years
    not necessary "must"... Android will exchange every not-fully-transparent pixel into solid white (or dk gray, depends on background color of status bar), only transparent ones will stay transparent
  • mvasco
    mvasco over 2 years
    Thank you @Tarik, I think my icon is ok for that use. But may be not. I will add it to my question to be sure.
  • mvasco
    mvasco over 2 years
    Thank you for your effort, I have downloaded your proposed link from Android Asset Studio, copied the respective drawable folders to res, and changed the AndroidManifest file including: <meta-data android:name="com.google.firebase.messaging.default_notifica‌​tion_icon" android:resource="@drawable/ic_stat_capenergy" />
  • mvasco
    mvasco over 2 years
    But the same result with the notification icon
  • Nitish
    Nitish over 2 years
    Is your meta-data tag inside you application class tag?
  • Nitish
    Nitish over 2 years
    Use this link to confirm if image source has been added to correct places. link
  • mvasco
    mvasco over 2 years
    Yes, I have followed exactly the given tutorial
  • mvasco
    mvasco over 2 years
    i know you are in the right way. I will try later from the beginning.Thank you for your time and effort.
  • Frank van Puffelen
    Frank van Puffelen over 2 years
    @TarikHuber: if the entire answer is in that link, please mark the question as a duplicate.