dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.89k stars 1.69k forks source link

AppIcon not displayed for Android 7 #23178

Closed Syed-RI closed 14 hours ago

Syed-RI commented 1 month ago

Description

App icon in the launcher and task switcher is not displaying for Android 7. However, Android 8 and up works Task_Switcher_Android8 AppIcon_Android8 Task_Switcher_Android7 AppIcon_Android7 png

Steps to Reproduce

Create a new maui app and deploy to an emulator running Android 7 (7.1.1) with a screen resolution of 1280 x 720. Or build and deploy the repro attached to same emulator.

Link to public reproduction project repository

https://github.com/Syed-RI/DeployTest

Version with bug

8.0.60 SR6

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 7.1.1

Did you find any workaround?

Works on Android 8 and up

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Equabyte commented 1 month ago

@Syed-RI I have an app in production compiled with 8.0.60 SR6 that is tested on physical devices with all supported Android versions including Android 7 and the app icon is showing correctly (despite its look not being the same as in latest Android versions). Image below is from a Samsung A3 2016 running Android 7 (last Android version supported on that device). So the issue you describe seems either device-specific or emulator related.

DCF_Calc_Android_7

Syed-RI commented 1 month ago

It happens on physical device as well. I think it is probably related to the screen resolution mine was 1280 x 720.Screenshot_20240621_180723_Jira.png

Equabyte commented 1 month ago

It happens on physical device as well. I think it is probably related to the screen resolution mine was 1280 x 720.

Galaxy A3 (2016) is also 720 x 1280 so it does not seem to be the resolution.

Equabyte commented 1 month ago

And here's your icon on my Galaxy A3 (2016) running Android 7:

deploy_test_icon

Syed-RI commented 1 month ago

And here's your icon on my Galaxy A3 (2016) running Android 7:

deploy_test_icon

Plot thickens

Equabyte commented 1 month ago

Plot thickens

There is a caveat though: Samsung Android 7 devices use an icon container by default (visible in my image) which may hide the true issue you are facing on your device/emulator. So indeed worth checking further in case Android 7 is really important to you; but according to this chart the share of Nougat users is now less than 1.5% worldwide.

Zhanglirong-Winnie commented 1 month ago

This issue has been verified using Visual Studio 17.11.0 Preview 2.1 (8.0.60 & 8.0.40 & 8.0.10). Can be reproduced on Android(7.1 &1280 x 720)platform. image

Syed-RI commented 1 month ago

There is a caveat though: Samsung Android 7 devices use an icon container by default (visible in my image) which may hide the true issue you are facing on your device/emulator. So indeed worth checking further in case Android 7 is really important to you; but according to this chart the share of Nougat users is now less than 1.5% worldwide.

This is for an enterprise app and we are committed to provide support for Android 7 and up. Besides, MAUI SDK itself supports Android 7 and up therefore I think this should be looked at. Probably needs a Resizetizer tweak? cc @mattleibow @Redth

mattleibow commented 1 month ago

I'll have a look. This is very weird as we have not really changed anything and there should be a drawable fallback.

mattleibow commented 1 month ago

OK, I managed to repro it... Not sure the issue yet as the images are there and the image works for Android 6.0.

I typically test Android 6, 9, 10, 13, 14 since they are on borders of major OS changes. They all work on those I believe, so Android 7 is giving us gifts of joy it seems.

mattleibow commented 1 month ago

I had a look and I see why this is happening:

This means that specifically for Android 7, the round icons are PNG files but for Android 8 they are adaptive icons.

So, the first workaround is to just drop round icons altogether. This means you will lose round icons on all Android versions, but just involves deleting the android:roundIcon="@mipmap/appicon_round" from your Platforms/Android/AndroidManifest.xml

If you still want round icons for new Android versions and maybe less concerned with the Android 7 app icon adherence to the "round" design, you could copy the generated icons from obj/Debug/net8.0-android/resizetizer/r/mipmap-*/appicon.png and add them to Platforms/Android/Resources/mipmap-*/appicon_round.png. Then in your csproj, you can add them as Android-specific resources: <AndroidResource Include="Platforms\Android\Resources\mipmap-*\*" />

This will just be a copy of the "legacy" icons and pretend they are round. But, if that is not viable, then you can potentially generate the round ones using a graphics program and place them in the same location. As long as you name it all the same as the other icons, they will just work together.

As soon as I have a fix for generating legacy round icons, I will link to it.

Syed-RI commented 1 month ago

I had a look and I see why this is happening:

This means that specifically for Android 7, the round icons are PNG files but for Android 8 they are adaptive icons.

So, the first workaround is to just drop round icons altogether. This means you will lose round icons on all Android versions, but just involves deleting the android:roundIcon="@mipmap/appicon_round" from your Platforms/Android/AndroidManifest.xml

If you still want round icons for new Android versions and maybe less concerned with the Android 7 app icon adherence to the "round" design, you could copy the generated icons from obj/Debug/net8.0-android/resizetizer/r/mipmap-*/appicon.png and add them to Platforms/Android/Resources/mipmap-*/appicon_round.png. Then in your csproj, you can add them as Android-specific resources: <AndroidResource Include="Platforms\Android\Resources\mipmap-*\*" />

This will just be a copy of the "legacy" icons and pretend they are round. But, if that is not viable, then you can potentially generate the round ones using a graphics program and place them in the same location. As long as you name it all the same as the other icons, they will just work together.

As soon as I have a fix for generating legacy round icons, I will link to it.

Awesome Matt!

We can live without the round icons so I'll look into it tomorrow. But IIRC, I have tried copying and pasting from resizetizer output and that broke the build as on next build resizetizer complained about same assets (i.e. appicon.png) being present in the dir.

mattleibow commented 1 month ago

resizetizer complained about same assets

Yeah, make sure to copy the appicon and rename to appicon_round. You will just need those variants as all the others are still generated.

mattleibow commented 1 month ago

This PR has the fixes to generate round icons for Android 7 https://github.com/dotnet/maui/pull/23276

mattleibow commented 1 month ago

/similarissues

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.