Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use tools:overrideLibrary in a build.gradle file?

I'm using the leanback libraries, which require Android 17 or later. However my app supports a minSDK of 16, so I get a build error from gradle saying

Error:Execution failed for task ':Tasks:processPhoneDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library /Users/mike/Projects/android-for-dummies-v3/Tasks/build/intermediates/exploded-aar/com.android.support/leanback-v17/21.0.2/AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="android.support.v17.leanback" to force usage

When I look at the build tools documentation, I see how to add the overrideLibrary marker to my manifest, but the problem is that I'm declaring my minSdk in my gradle file instead of in my manifest.

How do I use overrideLibrary when the minSdk is declared in build.gradle instead of in AndroidManifest.xml?

like image 460
emmby Avatar asked Nov 23 '14 22:11

emmby


People also ask

How do I fix a failed manifest merger?

The initial process would be to open the manifest application known as the AndroidManifest. xml and then click on the Merged Manifest tab below your edit pane. Following which, Click on the merged manifest option. An Error would be visible at the right column and then one must try to solve the error.

How do I open a merged manifest?

In Android Studio 3.3 you can also see Merged Manifest by clicking on Merged Manifest tab. It's showed at the bottom of the editor pane when you open your standard project manifest.

What is manifest placeholder?

Android Manifest usually contains pre-defined or static information which is then used to run the app. However, Android toolchain provides customization by allowing you to specify dynamic information through variable declaration, generally referred as Android Manifest placeholders.


4 Answers

Open Android Studio -> Open Manifest File

add <uses-sdk tools:overrideLibrary="android.support.v17.leanback"/> don't forget to include xmlns:tools="http://schemas.android.com/tools" too, before the <application> tag

enter image description here

like image 104
xDragonZ Avatar answered Oct 20 '22 01:10

xDragonZ


it doesn't matter that you declare your minSdk in build.gradle. You have to copy overrideLibrary in your AndroidManifest.xml, as documented here.

<manifest 
    ... >
<uses-sdk tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
    ...
</manifest>

The system automatically ignores the sdkVersion declared in AndroidManifest.xml.

I hope this solve your problem.

like image 43
icastell Avatar answered Oct 20 '22 01:10

icastell


<manifest xmlns:tools="http://schemas.android.com/tools" ... >
  <uses-sdk tools:overrideLibrary="nl.innovalor.ocr, nl.innovalor.corelib" />

I was facing the issue of conflict between different min sdk versions. So this solution worked for me.

like image 36
Kuldeep Saxena Avatar answered Oct 20 '22 02:10

Kuldeep Saxena


just changed only android:minSdkVersion="16" and it's work perfect C:\MyApp\platforms\android\CordovaLib\AndroidManifest.xml

like image 25
BIRJA KUMAR Avatar answered Oct 20 '22 00:10

BIRJA KUMAR