From 2eee3b4d7e1bba9cdc39882b4b1e764ec527907f Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 3 Oct 2023 16:30:50 +0100 Subject: [PATCH 1/3] [Xamarin.Android.Build.Tasks] Make manifestmerger.jar the default. Context https://github.com/xamarin/xamarin-android/issues/8387 The value for `AndroidManifestMerger` should be updated to be `manifestmerger.jar`. This allows users to make use of the new features like `AndroidManifestOverlay` out of the box. The old system is still available, the users will need to add the following to their csproj. ``` legacy ``` --- Documentation/guides/building-apps/build-properties.md | 9 ++++++--- .../Xamarin.Android.Common.targets | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Documentation/guides/building-apps/build-properties.md b/Documentation/guides/building-apps/build-properties.md index 54dc92d2606..151bb186e26 100644 --- a/Documentation/guides/building-apps/build-properties.md +++ b/Documentation/guides/building-apps/build-properties.md @@ -987,9 +987,12 @@ merging *AndroidManifest.xml* files. This is an enum-style property where `legacy` selects the original C# implementation and `manifestmerger.jar` selects Google's Java implementation. -The default value is currently `legacy`. This will change to -`manifestmerger.jar` in a future release to align behavior with -Android Studio. +The default value is currently `manifestmerger.jar`. If you want to +use the old version add the following to your csproj + +``` +legacy +``` Google's merger enables support for `xmlns:tools="http://schemas.android.com/tools"` as described in the [Android documentation][manifest-merger]. diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 71e64a76db7..c892a63885a 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -275,7 +275,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. False SHA256withRSA SHA-256 - legacy + manifestmerger.jar 1G From 06f816d1b75e683a0aa5a15039ba9729082a02ff Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 6 Oct 2023 15:01:17 +0100 Subject: [PATCH 2/3] Fix unit tests --- .../Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs | 2 ++ .../Tests/Xamarin.Android.Build.Tests/ManifestTest.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs index 6e1286fe27e..48e7457d97c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildWithLibraryTests.cs @@ -670,6 +670,8 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2, [V if (Builder.UseDotNet) { lib.RemoveProperty ("OutputType"); } + lib.AndroidManifest = lib.AndroidManifest. + Replace ("application android:label=\"${PROJECT_NAME}\"", "application android:label=\"com.test.foo\" "); // Create an "app" that is basically empty and references the library var app = new XamarinAndroidLibraryProject { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs index 1b97abb515d..c9fe8ffb548 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs @@ -755,6 +755,7 @@ public void MergeLibraryManifest () KnownPackages.SupportV7AppCompat_27_0_2_1, }, }; + proj.SetProperty ("AndroidManifestMerger", "legacy"); proj.Sources.Add (new BuildItem.Source ("TestActivity1.cs") { TextContent = () => @"using System; using System.Collections.Generic; From 58cc830ffa9c5887843defc6980debfab1ff2a6c Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Mon, 9 Oct 2023 10:35:01 -0400 Subject: [PATCH 3/3] Update build-properties.md Use XML formatting. --- Documentation/guides/building-apps/build-properties.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/guides/building-apps/build-properties.md b/Documentation/guides/building-apps/build-properties.md index 151bb186e26..55ce6c6f304 100644 --- a/Documentation/guides/building-apps/build-properties.md +++ b/Documentation/guides/building-apps/build-properties.md @@ -990,7 +990,7 @@ and `manifestmerger.jar` selects Google's Java implementation. The default value is currently `manifestmerger.jar`. If you want to use the old version add the following to your csproj -``` +```xml legacy ```