Open hansmbakker opened 1 year ago
I found somebody write on StackOverflow that
It appears that the manifestmerger is not able to merge the AndroidManifest.xml from multiple projects in the Android solution.
Android class libraries do not contain an AndroidManifest.xml
, as there is no mechanism to bundle and redistribute it. There isn't an MSBuild item group for the file type, etc.
However, what you could probably do for now as a workaround:
.aar
file -- it is just a .zip
file with the extension renamed.AndroidManifest.xml
in the root of the archive.aar
file in your project directory (next to .csproj
) fileWe do have a way for .aar
files to flow from class libraries to application projects. They also happen to support AndroidManifest.xml
files.
/cc @dellis1972 if you have other ideas here.
The AndroidManifestOverlay
will only work in the app project. The suggestion about packaging te file into an .aar "should" work.
We do have a way of packaging android resources into an aar for a clas library I think, so maybe just flagging it with AndroidManifest
in the class library will work. If it doesn't we should probably add that as an option.
Thank you both for the ideas! I'll try it early next week and share the outcome here.
@jonathanpeppers @dellis1972
Outcomes:
<AndroidManifest>Platforms\Android\AndroidManifest.xml</AndroidManifest>
to the first <PropertyGroup>
in the csproj filePlatforms\Android\AndroidManifest.xml
containing
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<queries>
<package android:name="<somePackageName-intentionally-removed>" />
</queries>
</manifest>
SomeAndroidManifestAdditions.aar
I verified both approaches by checking whether the contents of the AndroidManifest I wanted to merge ended up in ConsumingAppProjectDir\obj\Debug\net8.0-android\AndroidManifest.xml
Am I missing something?
Regarding
We do have a way for .aar files to flow from class libraries to application projects.
Should this be picked up automatically?
Wow! This must be one of the fastest fixes I've seen here! Thank you very much!
Should be fixed in https://github.com/xamarin/xamarin-android/pull/8273.
My bad, that PR isn't merged.
Is this to be expected to be worked on in the near future?
The PR which fixes this issue was deemed to much of a change to make it into the .net 8 release. It was then overlooked for inclusion in .net 9. That said, I have rebased the PR now, but I doubt we will be able to get it into the .net 9 release this might have to wait until the next major release. The main reasons for the caution is the change in bahaviour from existing library projects. We have no data on how this will effect user if AndroidManifest.xml files from library projects start getting included into the build system.
so i read this correct, that it will take about 16 month until this is in production available? serious?
i apprechiate the effort and quick resonse though.
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 17.8 Pre 1, .NET 8 preview 7
Description
I want to create a Maui class library that uses content provider queries to get data from another application.
For this, it is required to add the
queries
element to the Android Manifest.I want to automatically add the required element to the Android Manifest of the application project that consumes my library so that it works without manually modifying the Android manifest of that application.
I tried doing this using
<AndroidManifestOverlay Include="somefile.xml" />
.Steps to Reproduce
QueriesPackageRegistration.xml
with these contents:<AndroidManifestOverlay Include="QueriesPackageRegistration.xml" />
to the class library project file<AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>
- no ideas whether this is still needed in xamarin-android 13?queries
element is not output to the generated Android Manifest.Did you find any workaround?
No response
Relevant log output
No response