0

I'm using flutter_local_notifications 4.0.1+2 with my project and the notification icon is visible when running debug apk in emulator but the build apk it shows an colored square instead of the icon. can anyone help me with this issue?

Jason Brook
  • 15
  • 2
  • 5

2 Answers2

0

It might be that you didn't specify the notification icon at the correct place. It should be in the android/app/src/main/res/drawable folder, e.g. android/app/src/main/res/drawable/notification_icon.xml. Then, you can add

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

in android/app/src/main/AndroidManifest.xml. It might be that you specified your icon in android/app/src/debug/, which does not get taken into account when building your release apk.

Edit

An example of notification_icon.xml:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="221.9dp"
    android:height="208.1dp"
    android:viewportWidth="221.9"
    android:viewportHeight="208.1">
  <path
      android:pathData="M152.4,0h-83L0,208.1h221.9L152.4,0zM110.9,56.4l18.6,57.7l60.6,-0.1l-49.1,35.5l18.8,57.6l-49,-35.7l-49,35.7l18.8,-57.6L31.7,114l60.6,0.1L110.9,56.4z"
      android:fillColor="#006600"
      android:fillType="evenOdd" />
</vector>
Wessel
  • 617
  • 4
  • 13
  • this is working but the color is white so i cant see the icon, then i used icon color meta tag inside manifest file but the icon is still white. But the debug apk colors works fine – Jason Brook May 03 '21 at 14:41
  • You can specify the icon color with the fillColor property in the notification_icon.xml file. I added an example that would create a green icon. Again, make sure to make the edits in the main folder, not the debug one. – Wessel May 04 '21 at 15:25
  • im using a image file. these are my meta tags but icon color stays white – Jason Brook May 07 '21 at 12:28
  • Hmm I'm not sure what's going wrong then; maybe you can convert your image to a vectorized path and use the fillColor tag like in my example, which should work just fine if your image isn't too detailed. – Wessel May 08 '21 at 14:12
  • i did it as well with that also i can see the icon but its white. in white background i cant see the icon. i used a default clip art in this generator [Roman's Notification Icon Generator](https://romannurik.github.io/AndroidAssetStudio/index.html). – Jason Brook May 08 '21 at 17:10
  • i found the issue. i fixed it by generating the icons using android asset studio. and directed the icon meta tag to @mipmap/ic_launcher. – Jason Brook May 12 '21 at 12:46
0

For showing your custom app icon, you need to set icon in tag in Android Manifest file. Refer the following link, hope it may help you.

Change notification black box with custom app icon

Tutorial