APK errors

Manifest merger failed

Error text

Manifest merger failed with multiple errors, see logs
Attribute application@label value=(App) from AndroidManifest.xml is also present at [lib] value=(Lib).
Suggestion: add 'tools:replace="android:label"' to <application> element

Cause

The AndroidManifest files of the app and its libraries set the same attribute to different values. Gradle cannot merge them.

Step-by-step fix

  1. Read the "Suggestion" line under the error. Gradle writes the remedy itself.
  2. Add xmlns:tools to the <manifest> tag.
  3. Force your own value with tools:replace="android:label" on the clashing attribute.
  4. To cancel a permission another library asks for, use tools:node="remove".
  5. On Android 12 and up every <activity> with an intent filter needs an explicit android:exported.

Example commands

<manifest xmlns:tools="http://schemas.android.com/tools" ...>
  <application
      android:label="@string/app_name"
      tools:replace="android:label">
  </application>
</manifest>
./gradlew :app:processDebugMainManifest --stacktrace

How to prevent it

After editing the manifest, open the Merged Manifest view; the final result is shown there.

Author and license: Nibras Code