18

In my project minSdkVersion = 10, in the library it's 11.

I get:

BUILD_FAILED - Manifest merger failed : uses-sdk:minSdkVersion 10 cannot be smaller than version 11 declared in library.

How to ignore minSdkVersion of library?

Sufian
  • 6,405
  • 16
  • 66
  • 120
user1528799
  • 463
  • 1
  • 8
  • 18
  • change the library sources and import it as a module (fyi it will be 11 for a reason) so if you could "override" it to compile - then your app would crash on v10 making the overriding pointless – Blundell Dec 06 '14 at 20:33
  • possible duplicate of [Manifest merger failed : uses-sdk:minSdkVersion 14](http://stackoverflow.com/questions/24438170/manifest-merger-failed-uses-sdkminsdkversion-14) – tachyonflux Dec 06 '14 at 20:38
  • This is not a duplicate. I can't add library as a module, i add library by dint of gradle – user1528799 Dec 06 '14 at 20:50

2 Answers2

35

You need to change your project to library's value 11, because that attribute means that library was designed to be used at devices at least with API 11. It does not support API 10 at all, so you can not use it according requirements and minimal SDK of your project. See more details about < uses-sdk >

or

Find another library which will support API 10

UPDATE:

or

Use power of ManifestMerger. From official site.

Paragraph Markers

tools:overrideLibrary marker

A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version. Without such a marker, the manifest merger will fail. The marker will allow users to select which libraries can be imported ignoring the minimum SDK version.

Example, In the main android manifest :

<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
      tools:overrideLibrary="com.example.lib1, com.example.lib2"/>

will allow the library with the following manifest to be imported without error :

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.lib1">
    <uses-sdk android:minSdkVersion="4" />
</manifest>
Diederik
  • 5,536
  • 3
  • 44
  • 60
gio
  • 4,950
  • 3
  • 32
  • 46
  • The library supports API 10 and below (written documentation), but minSdkVersion is set to 11. You know, if I can get around this limitation? Maybe write something in Gradle. – user1528799 Dec 06 '14 at 21:29
  • 5
    See my update. You need to add into manifest file of your project `tools:overrideLibrary="your.library"` into `uses-sdk` – gio Dec 06 '14 at 21:42
  • Thanks! Also was an error - Invalid instruction 'overrideLibrary' Solution - http://stackoverflow.com/questions/26844886/importing-urban-airship-in-android-studio-gives-compile-issues – user1528799 Dec 06 '14 at 23:32
  • Will the IDE warn me if the library uses functions that are too new to the minSdkVersion I've used ? – android developer Oct 18 '17 at 12:38
  • @androiddeveloper not sure, I guess best is to try it with some simple project to be sure about how does it work – gio Oct 19 '17 at 10:24
  • is there a way to detect minsdk requirement for all libraries included in the gradle file? – Stack Diego Jan 28 '22 at 09:07
  • It doesn't help if the issue is with the `targetSdkVersion`. I mean if the target in the library is 32 and your app is 30, for example. – Dr.jacky Sep 06 '22 at 11:18
  • @Dr.jacky question is about `minSdkVersion`, nothing is related to `targetSdkVesrion` – gio Sep 06 '22 at 14:30
6

you have to declare in your manifest file as below

<uses-sdk tools:overrideLibrary="com.example.android" />

and do not forget to safe use of library like :

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {

//your code here
}
behrad
  • 1,228
  • 14
  • 21