Manifest merger failed : uses-sdk:minSdkVersion 14

AndroidAndroid StudioAndroid Gradle-PluginAndroid 5.0-Lollipop

Android Problem Overview


Since downloading the latest SDK and installing Android Studio, my project fails to build. I get the following message:

Error:Gradle: Execution failed for task ':SampleProject:processProdDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1

Android Solutions


Solution 1 - Android

Note: This has been updated to reflect the release of API 21, Lollipop. Be sure to download the latest SDK.

In one of my modules I had the following in build.gradle:

dependencies {
    compile 'com.android.support:support-v4:+'
}

Changing this to

dependencies {
    // do not use dynamic updating.
    compile 'com.android.support:support-v4:21.0.0' 
}

fixed the issue.

Make sure you're not doing a general inclusion of com.android.support:support-v4:+ or any other support libraries (v7, v13, appcompat, etc), anywhere in your project.

I'd assume the problem is v4:+ picks up the release candidate (21.0.0-rc1) latest L release which obviously requires the L SDK.

Edit:

If you need to use the new views (CardView, RecyclerView, and Palette), the following should work:

compile "com.android.support:cardview-v7:21.0.0"
compile "com.android.support:recyclerview-v7:21.0.0"
compile "com.android.support:palette-v7:21.0.0"

(Credit to EddieRingle on /androiddev - http://www.reddit.com/r/androiddev/comments/297xli/howto_use_the_v21_support_libs_on_older_versions/)

Another Edit

Be sure to see @murtuza's answer below regarding appcompat-v7 and upvote if it helps!

Solution 2 - Android

Also, in case you are importing the appcompat-v7 library make sure you tag a version number at the end of it like so:

compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'

After only changing the support-v4 version, I still received the error: > Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1

It was a bit confusing because it looks like v4 is still the problem, but, in fact, restricting the appcompat v7 version fixed the problem.

Solution 3 - Android

Solution 1:

Change uses-sdk to <uses-sdk tools:node="replace" /> and add xmlns:tools="http://schemas.android.com/tools" in AndroidManifest.xml

 <?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.demo.android"
    android:versionCode="16"
    android:versionName="3.3.1">
    .
    .
    <uses-sdk tools:node="replace" />
    .
    .
</manifest>

Make sure you use gradle 0.11 and above to use Manifest merger.

Solution 2:

  • Change compile 'com.android.support:support-v4:+' to compile 'com.android.support:support-v4:20.+' in build.gradle. This will prevent gradle from using v4:21.0.0 that requires version L.

  • However, if your any of your external dependencies uses the same. You will probably have to wait for them to update the same.

Solution 3:

  • Remove/Comment <version>21.0.0-rc1</version> in your file <android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml

  • Repeat the same for support-v7

Solution 4 - Android

<uses-sdk tools:node="replace" />

No longer works.

change uses-sdk to

<uses-sdk tools:overrideLibrary="com.packagename.of.libary.with.conflict" />

and add
xmlns:tools="http://schemas.android.com/tools" in the AndroidManifest.xml file

Solution 5 - Android

The problem still arises with transitive dependencies. Gradle offers a way to force the usage of a specific version of a dependency.

For example you can add something like:

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:20.+'
        force 'com.android.support:appcompat-v7:20.+'
    }
}

to your build.gradle.

If you want to learn more about gradle resolution strategies refer to this guide http://www.gradle.org/docs/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html

I found this while reading the corresponding issue which I will link here

Solution 6 - Android

Adding to the correct answers above, the problem still might occur due to library nesting. In this case, try as the example below:

compile 'com.android.support:support-v4:20.+'
compile ('com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+') { // example
    exclude group: 'com.android.support', module:'support-v4'
    exclude group: 'com.android.support', module:'appcompat-v7'
}

Solution 7 - Android

In the build.gradle file, It was by default compile 'com.android.support:support-v4:+' so when you build the gradle projecit would consider, com.android.support:support-v4:21.0.0-rc1 because of the recent L developer preview release.

Make changes in the following line and it will resolve the issue. Change

compile 'com.android.support:support-v4:+' 

to

compile 'com.android.support:support-v4:20.+'

Similarly when using v7-appcompat support library, make the change from

compile 'com.android.support:appcompat-v7:+'

to

compile 'com.android.support:appcompat-v7:20.+'.

Solution 8 - Android

for people building hybrid apps using cordova CLI, this command will help:

cordova build android -- --minSdkVersion=15

yes it uses double double dashes as you saw it.

Solution 9 - Android

For people facing this issue in the Android Studio beta, the accepted answer didn't solve my problem. Importing a project downloaded from GitHub, I had the following in my build.gradle file of app giving an error in question:

 dependencies {
    compile 'com.android.support:support-v4:+'
}

But in my external library folder I have this folder:

support-v4-21.0.0-rc1 //note the 21

I solved the above problem by changing the dependency to:

dependencies {
compile 'com.android.support:support-v4:20.+' //20 used less than available strange but works
}

Note: you might also need to download api level lower than the currently available in Android Studio for some library and projects for this to work properly.

Solution 10 - Android

I also had the same issue and changing following helped me:

from:

dependencies {
    compile 'com.android.support:support-v4:+'

to:

dependencies {
 compile 'com.android.support:support-v4:20.0.0'
}

Solution 11 - Android

I solved the problem by editing the line below in build.gradle and it works! :-)

adding version 20.+'

From

 dependencies {
    	compile 'com.android.support:appcompat-v7:+'
    }

To

dependencies {
	compile 'com.android.support:appcompat-v7:20.+'
}

Solution 12 - Android

compile('com.android.support:support-v4:19.1.0'){
    force = true
}

Helped me, taken from here

Solution 13 - Android

You have to configure all the supports and appcompat libraries with version 19.+

If the recommendation of leave the support library with the 19.+ version doesn't works you can try the next tip in your AndroidManifest file.

First add this code:

xmlns:tools="http://schemas.android.com/tools"

And then, at the application level (not inside application!)

<uses-sdk tools:node="replace" />

Solution 14 - Android

I make all of the solutions in here with no result, so i look in another place and i found a way to trick the IDE, so you have to put a line in the Mainfest to make the Gradle use a different one, the one that you put on build.gradle the line is:

<uses-sdk tools:node="replace" />

just it, and it work.

I hope it helps.

Solution 15 - Android

You need to remove from build.gradle compile 'com.android.support:support-v13:+'

Solution 16 - Android

Here's the new bug filed for this btw https://code.google.com/p/android/issues/detail?id=72430

Assuming you are using the Support Repository, the workaround is to comment or remove the line

21.0.0-rc1 in the local Maven repo listing file at /extras/android/m2repository/com/android/support-v4/maven-metadata.xml

Solution 17 - Android

For me the issue like this is solved by changing the

minSdkVersion 14

In the build.gladdle file and use the one that is specified in the error message

but the issue was

Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 15 declared in library

So I changed from 14 to 15 in the build.gladdle file and it works

give it a try.

Solution 18 - Android

Just target the required minSdkVersion i.e change to the needed one In my case minSdkVersion was 14.

Changing to minSdkVersion 16 solved the issue

compileSdkVersion 29
    defaultConfig {
        applicationId "e.futaaapp"
        minSdkVersion 14
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

compileSdkVersion 29
    defaultConfig {
        applicationId "e.futaaapp"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

Solution 19 - Android

Don't forget, you should edit build.gradle in 'app' subfolder of your project, not in project's folder. I've lost a working day trying to solve a problem with version "L".

Solution 20 - Android

Try deleting the build folder(s) in your project and resync your gradle project to rebuild it. Also, like others have said in this post - instead of doing something like this:

compile 'com.android.support:support-v4:19.+'

do this:

compile 'com.android.support:support-v4:19.1.0'

Solution 21 - Android

Thank you @Murtuza. Your answer helped me to solve my problem but in my case

compile 'com.android.support:support-v13:19.+ also, along with

compile 'com.android.support:support-v4:19.+' compile 'com.android.support:appcompat-v7:19.+'

from compile 'com.android.support:support-v4:+' compile 'com.android.support:support-v7:+' compile 'com.android.support:support-v13:+' Hope this might help some one

Solution 22 - Android

I have the second solution:

  1. unzip https://dl.dropboxusercontent.com/u/16403954/android-21.zip to sdk\platforms\

  2. change build.gradle like

     compileSdkVersion 21
     buildToolsVersion "20.0.0"
    
     defaultConfig {
         applicationId "package.name"
         minSdkVersion 10
         targetSdkVersion 21
         versionCode 1
         versionName "1.0"
     }
    
  3. add

     <uses-sdk tools:node="replace" /> 
    

    in Manifest with xmlns:tools="schemas.android.com/tools";

  4. Go to sdk\extras\android\m2repository\com\android\support\support-v4\21.0.0-rc1\

unpack support-v4-21.0.0-rc1.aar and edit AndroidManifest.xml like

from

<uses-sdk
        android:minSdkVersion="L"
        android:targetSdkVersion="L" />

to

<uses-sdk
        android:minSdkVersion="4"
        android:targetSdkVersion="21" />

P.S. You can do this with all support libraries that need.

Solution 23 - Android

I have some projects where I prefer to target L.MR1(SDKv22) and some projects where I prefer KK(SDKv19). Your result may be different, but this worked for me.

// Targeting L.MR1 (Android 5.1), SDK 22
android {
    compileSdkVersion 22
    buildToolsVersion "22"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 22
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // google support libraries (22)
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:cardview-v7:21.0.3'
    compile 'com.android.support:recyclerview-v7:21.0.3'
}



// Targeting KK (Android 4.4.x), SDK 19
android {
    compileSdkVersion 19
    buildToolsVersion "19.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    // google libraries (19)
    compile 'com.android.support:support-v4:19.1+'
    compile 'com.android.support:appcompat-v7:19.1+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
}

Solution 24 - Android

In Android Studio 1.1.0: File - Project Structure - Tab Flavors - Select Min SDK Version which is higher than in Manifest

Solution 25 - Android

The only thing that worked for me is this:

In project.properties, I changed:

cordova.system.library.1=com.android.support:support-v4:+ to cordova.system.library.1=com.android.support:support-v4:20.+

Solution 26 - Android

You just change Minimum API Level from Build Settings -> Player Settings -> Other Settings -> Minimum SDK Level to some higher version.

Solution 27 - Android

The best way is to let the Android Studio fix the issue.

I did the below, and it worked fine.

  1. Open your project in Android Studio, errors will be popup, if there is a link given to fix it click on it.

  2. Re-open your project in Android Studio, errors will be popup, there will be a link this time if it's not given in the Step 1, click on the given link to fix it.

Note that both operations took several minutes of time, but fixed all issues.

Solution 28 - Android

Solution: Manifest merger failed Attribute application@ppComponentFactory ...

If you are using any latest & greatest Firebase libraries or any other libraries, those are actually using AndroidX instead of android.support then you might have the issue as Manifest merger failed!! So, in this case, your project needs to migrate to AndroidX. So follow the link: https://firebase.google.com/support/release-notes/android#update_-_june_17_2019

Or watch this video. https://youtu.be/RgveQ4AY1L8 Thank you.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionloeschgView Question on Stackoverflow
Solution 1 - AndroidloeschgView Answer on Stackoverflow
Solution 2 - AndroidmurtuzaView Answer on Stackoverflow
Solution 3 - AndroidGaurav AroraView Answer on Stackoverflow
Solution 4 - AndroiduserM1433372View Answer on Stackoverflow
Solution 5 - AndroidkoesclemView Answer on Stackoverflow
Solution 6 - AndroidLeonardo CardosoView Answer on Stackoverflow
Solution 7 - AndroidBhargav JhaveriView Answer on Stackoverflow
Solution 8 - AndroidProllyGeekView Answer on Stackoverflow
Solution 9 - AndroidIllegal ArgumentView Answer on Stackoverflow
Solution 10 - Androidmin2broView Answer on Stackoverflow
Solution 11 - AndroidCristiana ChavezView Answer on Stackoverflow
Solution 12 - AndroidLina ShyshovaView Answer on Stackoverflow
Solution 13 - AndroidAracemView Answer on Stackoverflow
Solution 14 - AndroidDavid Moreno CanteroView Answer on Stackoverflow
Solution 15 - AndroidIgor KostenkoView Answer on Stackoverflow
Solution 16 - AndroidLemonGentryView Answer on Stackoverflow
Solution 17 - AndroidRuberandinda PatienceView Answer on Stackoverflow
Solution 18 - AndroidKimanthi K.View Answer on Stackoverflow
Solution 19 - AndroidCoolMindView Answer on Stackoverflow
Solution 20 - AndroidIgorGanapolskyView Answer on Stackoverflow
Solution 21 - AndroidDeepthiView Answer on Stackoverflow
Solution 22 - AndroidVova K.View Answer on Stackoverflow
Solution 23 - AndroidAG1View Answer on Stackoverflow
Solution 24 - Androidea_View Answer on Stackoverflow
Solution 25 - AndroidabelabbesnabiView Answer on Stackoverflow
Solution 26 - AndroidCodemakerView Answer on Stackoverflow
Solution 27 - AndroidManohar Reddy PoreddyView Answer on Stackoverflow
Solution 28 - AndroidSubhojit HalderView Answer on Stackoverflow