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: 2017-10-04 16:43 UTC (History)
10 users (show)

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


Attachments

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. ***

Note You need to log in before you can comment on or make changes to this bug.