Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Gradle Manifest merger failed

I use the leanback library to develop for Android TV. My app declare the min API to 16 however the leanback as a minimum API of 16. So as the documentation says I declared this in my manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="com.mypackage.package">

    <uses-sdk tools:overrideLibrary="android.support.v17.leanback" />

However I still have the error :

Error:(6, 5) Execution failed for task ':app:processAdhocProdManifest'.

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library /thepathtotheapp/build/intermediates/exploded-aar/com.android.support/leanback-v17/22.2.0/AndroidManifest.xml Suggestion: use tools:overrideLibrary="android.support.v17.leanback" to force usage

in the Manifest merger report I can see :

MERGED from io.fabric.sdk.android:fabric:1.0.2:7:5
    android:targetSdkVersion
        INJECTED from AndroidManifest.xml:0:0
        INJECTED from AndroidManifest.xml:0:0
    android:minSdkVersion
        INJECTED from AndroidManifest.xml:0:0
        INJECTED from AndroidManifest.xml:0:0
    tools:overrideLibrary
        ADDED from AndroidManifest.xml:21:15
    tools:ignore
        ADDED from com.mixpanel.android:mixpanel-android:4.5.4-RC1:14:9
application
ADDED from AndroidManifest.xml:23:5

So it look like it's adding the tools:overrideLibrary but it still fail.

Anyone knows how to fix this ?

like image 236
Andros Avatar asked Jun 26 '15 00:06

Andros


People also ask

How do I fix manifest merger failed?

Try adding the following labels to resolve the issue: Add the xmlns:tools line in the manifest tag. Add tools:replace= or tools:ignore= in the application tag.

How do I merge manifest files on Android?

If two manifests have the same XML element, then the tool merges the two elements together using one of three merge policies: Merge. Combine all non-conflicting attributes into the same tag and merge child elements according to their respective merging policy.

What is Android exported true?

The exported attribute is used to define if an activity, service, or receiver in your app is accessible and can be launched from an external application. As a practical example, if you try to share a file you'll see a set of applications available.


1 Answers

The issue was coming from Mixpanel library, Mixpanel define its AndroidManifest with this tag :

<uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="21"
        tools:ignore="GradleOverrides" />

So I end up giving up on Mixpanel, I prefer give up on them than 10% of our users.

like image 179
Andros Avatar answered Oct 11 '22 14:10

Andros