Tools: Replace Not Replacing in Android Manifest

Manifest Merger error - tools:replace not working

In my case,

removing tools:ignore from the Manifest files and adding tools:replace="allowBackup,supportsRtl" worked for me.

Update:

One more solution looks promising, however I never tried it.

 <application
xmlns:tools="http://schemas.android.com/tools" <-- added tools on application tag
android:name=".ABC"
android:allowBackup="false"
android:fullBackupContent="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="false"
android:theme="@style/Theme"
tools:replace="allowBackup,supportsRtl"
tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">

add 'tools:replace=android:label' to application element at AndroidManifest.xml:16:5-39:19 to override

The error message is telling you that in you AndroidManifest.xml your android:label with value flutter_bloc_pattern is already present in the manifest of (library/plugin/project) DynamsoftBarcodeReader.

You could, as the error says, add tools:replace="android:label" to your <application> node in your manifest

<application
tools:replace="android:label"
android:name="io.flutter.app.FlutterApplication"
android:label="flutter_bloc_pattern"
android:icon="@mipmap/ic_launcher">

If you add the tools attribute you need also to add the schema

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="nz.co.plumbingworld.flutterblocpattern">

What does the `tools:replace` attribute do in an Android Manifest file?

tools:replace is an attribute marker which can be used to reconfigure the main manifest file by merging specific manifest setups from project flavors (build variants).

Let's say you have the next node in the main manifest, where a specific Activity is defined as exported:

<activity android:name="com.example.ActivityTest"
android:exported="true">
...

But for a specific flavor (build variant), the same Activity shouldn't be exported. So, you define a barebone manifest file within the flavor folder, and add the node with the replacement attribute:

<activity android:name="com.example.ActivityTest"
android:exported="false"
tools:replace="android:exported">
...

When selecting the target flavor in Active Build Variant, the build system will merge both manifests, and replace in the main manifest node the android:exported attribute with flavor's one.

To summarize, you use this attribute marker when you have multiple project flavors, and each need to define different attributes for existing nodes defined in the main manifest file.

Notice that you can also replace a full node completely by adding instead tools:node="replace".

Manifest merger failed error (tools:replace=android:launchMode)

The problem is with com.aware.ui.PermissionsHandler, which is why putting attributes on .MainActivity will not help, as that is a different activity. Since you are using artifacts in your posted Gradle files, I'm not sure where you were modifying the manifests of the libraries.

In your app's manifest, add:

<activity
android:name="com.aware.ui.PermissionsHandler"
android:launchMode="..."
tools:replace="android:launchMode"
/>

where ... is your desired launchMode value, perhaps after some discussion with the developers of those libraries to determine what the right answer is.

You shouldn't need any other attributes or child elements — they should all get merged in via the manifest merger process.



Related Topics



Leave a reply



Submit