dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 527 forks source link

Support ManifestMerger from the Android SDK #2687

Closed erikpowa closed 4 years ago

erikpowa commented 5 years ago

Currently hitting invalid/unmerged <service> in merged manifest. (firebase-auth + firebase-firestore)

  <service
                android:name="com.google.firebase.components.ComponentDiscoveryService"
                android:exported="false" >
            <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.auth.FirebaseAuthRegistrar"
                    android:value="com.google.firebase.components.ComponentRegistrar" />
        </service>

        <service android:name="com.google.firebase.components.ComponentDiscoveryService">
            <meta-data
                    android:name="com.google.firebase.components:com.google.firebase.firestore.FirestoreRegistrar"
                    android:value="com.google.firebase.components.ComponentRegistrar"/>
        </service>

Is there any plan to support the tool from Android SDK? (The current implementation is kinda like this).

Manifest Merger CLI ``` Android Manifest Merger Tool Version 2 Usage: Merger --main mainAndroidManifest.xml --log [VERBOSE, INFO, WARNING, ERROR] --libs [path separated list of lib's manifests] --overlays [path separated list of overlay's manifests] --property [PACKAGE | VERSION_CODE | VERSION_NAME | MIN_SDK_VERSION | TARGET_SDK_VERSION | MAX_SDK_VERSION | NAME | TARGET_PACKAGE | FUNCTIONAL_TEST | HANDLE_PROFILING | LABEL=value] --placeholder [name=value] --out [path of the output file] ```

Tested it where
`--main` pointed to `\Properties\AndroidManifest.xml`
`--libs` to `\90\lp\....\jl\AndroidManifest.xml`
`--overlays` to a custom overlay.xml with XA/mono stuph
main.xml ```xml ```
overlay.xml ```xml ```

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:installLocation="auto" android:versionCode="1" package="com.example" android:versionName="1.0.0-alpha1">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<application android:allowBackup="false" android:hardwareAccelerated="true" android:label="Example" android:theme="@style/AppTheme.NoActionBar" android:icon="@mipmap/ic_launcher">
    <meta-data android:name="com.google.android.geo.API_KEY" android:value="REMOVED" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="REMOVED" />
    <uses-library android:name="org.apache.http.legacy" android:required="true" />
</application>

valid_output.xml ```xml ```
JonDouglas commented 5 years ago

I believe you are asking for proper manifest merging as outlined here: https://github.com/xamarin/xamarin-android/issues/1335

I would highly recommend adding your issue in that thread and providing an upvote (👍) so we can prioritize work on this.

Secondly, as for the manifest merger tool, are you referring to the manifest-merger.jar found inside {SDK}\tools\lib?

erikpowa commented 5 years ago

@JonDouglas

1335 Sounds more like an enhancement to manifest merger. The SDK's merger already has --overlay, that makes it easy to "plug and play" that feature (something like <AndroidManifestOverlay Inclide="overperm.xml" Order="999">).

Yes, from the tools\lib. (as standalone, from maven, it takes ~19.4MB with all of it's dependencies, 26.5.0-alpha03, so, from sdk is better choice)

brendanzagaeski commented 4 years ago

Release status update

A new Release version has now been published that includes the new feature for this item, as implemented in https://github.com/xamarin/xamarin-android/commit/9afac535ad12c64c0459384d48202e2f43964724.

Feature included in Xamarin.Android 10.2.0.100.

Feature included on Windows in Visual Studio 2019 version 16.5. To get the new version that includes the feature, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.

Feature included on macOS in Visual Studio 2019 for Mac version 8.5. To get the new version that includes the feature, check for the latest updates on the Stable updater channel.

To enable the new behavior, set the $(AndroidManifestMerger) MSBuild property to manifestmerger.jar in the .csproj file:

<PropertyGroup>
  <AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>
</PropertyGroup>

See the release notes for additional details.