2

I have a 110x110 image in android/app/src/main/res/drawable/notification.png for my notification icon. When I flutter run this on my device, it displays correctly. However, if I flutter build apk and install the resulting .apk, my notification is a square white box. I've unpacked the .apk and the image at android/app/src/main/res/drawable/notification.png is now 1x1.

I've tried aaptOptions { cruncherEnabled = false } and release {crunchPngs false}

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Did you add the meta-data of notification icon in manifest? – Amir Mohammad Shams Mar 22 '23 at 11:24
  • @AmirMohammadShams no – pinoyyid Mar 22 '23 at 11:25
  • @AmirMohammadShams I'm not using firebase messaging. These are local notifications – pinoyyid Mar 22 '23 at 11:29
  • Most likely one of the used [flutter] libraries also has a file of that name and thus overwrites your image. You should better use a different file name. – Robert Mar 22 '23 at 16:16
  • @Robert the actual filename is distinct to my app so that's not the cause. – pinoyyid Mar 22 '23 at 16:49
  • `notification.png` is not distinct name. A different reason for the image to be changed could be the "image optimization" step: https://stackoverflow.com/q/12929884/150978 – Robert Mar 22 '23 at 17:20
  • @Robert thx for the suggestion. From that link I tried adding `crunchPngs false` but I'm still getting 1x1 png files in the apk. – pinoyyid Mar 22 '23 at 21:34
  • Can you replace your PNG file by something different that is not a PNG file? If it ends up with the same one pixel PNG file (same file content) your file is overwritten and not converted. – Robert Mar 22 '23 at 21:37
  • @Robert it's not being overwritten. This is something within the gradle build release chain. For now I've worked around it by extracting the app-release.apk, replacing the broken .png files with their originals, and then rezipping and re-signing the .apk. – pinoyyid Mar 22 '23 at 23:33

0 Answers0