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 ?

Andros
  • 4,069
  • 1
  • 22
  • 30
  • Well, the point behind `tools:overrideLibrary` is for you to then supply a replacement value: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger#TOC-tools:overrideLibrary-marker I don't see where you are doing that. – CommonsWare Jun 26 '15 at 00:20
  • It's specified in my build.gradle file, I remove it from the build.gradle file and I specified : directly in the AndroidManifest But I still have the exact same error. – Andros Jun 26 '15 at 00:25
  • Hmmmm... I haven't used `tools:overrideLibrary` yet, and so I was hoping that perhaps putting the values in `` would help. You could try switching from `tools:overrideLibrary="..."` to `tools:node="replace"`, which in theory should replace all lower-priority instances of `` with yours. I have used `tools:node="replace"`, but not on ``. – CommonsWare Jun 26 '15 at 00:33
  • 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. – Andros Jun 26 '15 at 00:38
  • 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](http://stackoverflow.com/a/27310430/115145) looks like it has that value, and 65 people think it helped. Perhaps something changed/broke since December? – CommonsWare Jun 26 '15 at 00:42
  • 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. – Andros Jun 26 '15 at 00:46

1 Answers1

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.

Andros
  • 4,069
  • 1
  • 22
  • 30