Skip to content

Automatically add MauiIcon to AndroidManifest.xml#8063

Closed
mattleibow wants to merge 1 commit intonet6.0from
dev/androidmanifest
Closed

Automatically add MauiIcon to AndroidManifest.xml#8063
mattleibow wants to merge 1 commit intonet6.0from
dev/androidmanifest

Conversation

@mattleibow
Copy link
Copy Markdown
Member

@mattleibow mattleibow commented Jun 15, 2022

Re-PR of #7968

Description of Change

On Android (and iOS / Mac Catalyst) the app icons are not actually added to the manifests because that code was not written. For some reason I had determined that people would always use the same filename and thus the templates would be good - and somehow knowledge would arrive in the brains of devs to go change values in the platform files when editing the csproj.

This was obviously wrong and even though the docs are technically incorrect because they do not state that you have to change values in the manifest, this PR goes ahead and does the expected thing and makes sure there is an icon in the manifest.

NOTE: the Android templates change here to no longer explicitly set the icon in the working directory, but existing users will still have it. This needs to be documented on how to remove and/or specify: dotnet/docs-maui#611

Issues Fixed

@mattleibow mattleibow requested a review from a team as a code owner June 15, 2022 13:45
@mattleibow mattleibow added this to the 6.0-sr2 milestone Jun 15, 2022
@mattleibow mattleibow added the area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer label Jun 15, 2022
@mattleibow mattleibow self-assigned this Jun 15, 2022
@mattleibow mattleibow linked an issue Jun 15, 2022 that may be closed by this pull request
@mattleibow
Copy link
Copy Markdown
Member Author

@jonathanpeppers mentions: #8020 (comment)

I'd prefer to put this in the Android workload? If this is only for <application android:icon="" android:roundIcon="" />, can we just add MSBuild properties for both of these?

However, since the functionality is very inconsistent right now and is causing major confusion, I would like to make MAUI do this, then when Android gets the feature (and iOS) then we can remove these changes.

Comment on lines +695 to +699
<GenerateAndroidManifestXml
AppIcon="@(MauiImage->WithMetadataValue('IsAppIcon', 'true'))"
Manifest="$(IntermediateOutputPath)android\AndroidManifest.xml"
IntermediateOutputPath="$(IntermediateOutputPath)android"
GeneratedFilename="AndroidManifest.xml" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think writing directly to $(IntermediateOutputPath)android\AndroidManifest.xml is a good idea. If that file changes, it skips Fast Deployment. It will have to build, sign, and adb install the .apk. There aren't any tests that deploy apps checking targets skip & the overall time is under a threshold. We have those in the xamarin-android repo.

Could we fix this in .NET 7 instead? And introduce new MSBuild properties in the Android, iOS, etc. workloads?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, could you write to MAUI's own manifest and use the manifest merging feature?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we just need to document this and fix it in net7 then. @Redth @davidortinau @davidbritch

@mattleibow
Copy link
Copy Markdown
Member Author

@mattleibow mattleibow closed this Jul 18, 2022
@mattleibow mattleibow deleted the dev/androidmanifest branch July 18, 2022 23:27
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android does not automatically update the manifests with MauiIcon

2 participants