Android Gradle Manifest merger failed
Asked Answered
K

1

6

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 ?

Kissel answered 26/6, 2015 at 0:15 Comment(6)
Well, the point behind tools:overrideLibrary is for you to then supply a replacement value: tools.android.com/tech-docs/new-build-system/user-guide/… I don't see where you are doing that.Limb
It's specified in my build.gradle file, I remove it from the build.gradle file and I specified : <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="16" tools:overrideLibrary="android.support.v17.leanback"/> directly in the AndroidManifest But I still have the exact same error.Kissel
Hmmmm... I haven't used tools:overrideLibrary yet, and so I was hoping that perhaps putting the values in <uses-sdk> would help. You could try switching from tools:overrideLibrary="..." to tools:node="replace", which in theory should replace all lower-priority instances of <uses-sdk> with yours. I have used tools:node="replace", but not on <uses-sdk>.Limb
Good idea but unfortunately : uses-sdk element cannot have a "tools:node" attribute . So I tried with "merge" as well instead of "replace" but still the same issue than before.Kissel
Well, my only other idea is that the error message is wrong and the library's package name is something else. But this SO answer looks like it has that value, and 65 people think it helped. Perhaps something changed/broke since December?Limb
It's my only library with a minSdkVersion at 17 and the package name seems correct. So either something changed/broke or I do something wrong ... thanks for the help anyway.Kissel
K
8

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.

Kissel answered 26/6, 2015 at 1:55 Comment(3)
Having the same issue, but looks like mixpanel has some updates to fix this? github.com/mixpanel/mixpanel-android/releasesGuizot
Apparently yes, you should update and give it a try. I don't use Mixpanel anymore...Kissel
I can confirm that their update 4.8.0 fixed merging conflicts.Tanberg

© 2022 - 2024 — McMap. All rights reserved.