Bug 52857 - Support more advanced features of AndroidManifest.xml merging
Summary: Support more advanced features of AndroidManifest.xml merging
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.1 (C9)
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: dean.ellis
URL:
: 48153 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-02-27 18:30 UTC by Jon Douglas [MSFT]
Modified: 2018-03-30 02:57 UTC (History)
15 users (show)

Tags: bb
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 52857 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Jon Douglas [MSFT] 2017-02-27 18:30:22 UTC
*Description:

Our current AndroidManifest.xml merging process seems to be a bit limited. There are many use-cases where advanced manifest merging rules are needed to accomplish certain tasks within application development.

Gradle build currently supports quite an extensive AndroidManifest.xml merging process. You can see details outlined here:

https://developer.android.com/studio/build/manifest-merge.html

These are mainly accomplished with merge rule markers defined by the xmlns:tools="http://schemas.android.com/tools".

Sample inside a <manifest>:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp"
    xmlns:tools="http://schemas.android.com/tools">

Within these tools, there are different markers that apply a rule. Here are a couple of examples:

tools:node="merge" - Merges all attributes in this tag and all nested elements given there are no conflicts

tools:node="merge-only-attributes" - Merge all attributes in this tag only, do not merge nested elements

tools:node="remove" - Remove the element from the merged manifest

tools:node="removeAll" - Remove all elements matching the type

tools:node="replace" - Replace the lower priority element

tools:node="strict" - Creates a build failure when the element in lower priority doesn't match the high priority manifest rule

There is also a concept of Attribute Markers in which you can apply merge rules to specific attributes.

https://developer.android.com/studio/build/manifest-merge.html#attribute_markers

For example I could apply one of rules without the "node" definition to an attribute instead:

High Priority:

<activity android:name=”com.example.ActivityOne”
    android:screenOrientation=”portrait”
    tools:remove=”android:windowSoftInputMode”>

Low Priority:

<activity android:name=”com.example.ActivityOne”
    android:windowSoftInputMode=”stateUnchanged”>

Thus would remove the "android:windowSoftInputMode" attribute.

Final:

<activity android:name=”com.example.ActivityOne”
    android:screenOrientation=”portrait”>

All of these features would be extremely useful for MSBuild and Xamarin.Android. It would allow application developers to customize their build process when dealing with third party SDKs and complex manifest merging that might add unwanted nodes/attributes to their application. This is common in native Android app development that involve advanced manifest merging tactics.

Whether this is supported in XML or via the Xamarin.Android flavored Attributes, it would cause less grief on our customers who try to integrate with third party libraries and need to customize the manifest merging process.

*Version Information

Xamarin 4.3.0.784

Xamarin.Android 7.1.0.41
Comment 2 Ken Sykora 2017-02-27 20:01:12 UTC
Related Issue: https://bugzilla.xamarin.com/show_bug.cgi?id=48153
Comment 4 Jon Douglas [MSFT] 2017-10-04 16:43:45 UTC
*** Bug 48153 has been marked as a duplicate of this bug. ***
Comment 5 George Josh Karabin 2017-10-26 17:45:57 UTC
Adding a +1; I maintain a nuget at my company that's used for a number of internal projects. It would benefit from features to allow its users to override some of its permissions requests.
Comment 6 Reuben Tanner 2018-02-06 20:56:38 UTC
+1 - my team needs this as well
Comment 7 James 2018-02-26 08:01:04 UTC
added a feature request on github as per Jon for this
https://github.com/xamarin/xamarin-android/issues/1335
Comment 8 Trevor 2018-03-30 02:57:40 UTC
+1 - this is critical for us as we try to move from GCM to Firebase Messaging.