237

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
4

28 Answers 28

312

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!

12
  • 3
    What about a library compiled from Maven ? How to exclude the "old" dependancy ?
    – Arnaud
    Jun 26, 2014 at 19:41
  • 4
    @Arnaud compile("blah:blah:bla") {exclude group: 'com.android.support', module: 'support-v4'} Jun 27, 2014 at 7:12
  • 3
    Note that to use CardView, RecyclerView and Palette, you will also have to alter your Manifest to avoid the merge conflict gradle throws. See this link for details: reddit.com/r/androiddev/comments/297xli/…
    – Michel
    Jun 28, 2014 at 21:50
  • 3
    Never, ever, suggest people to use + in the dependency version. ALWAYS specify the exact version of the library you want to use (or is available at the time you write the code). Even 20.+ is bad. And if a library you depends on follow this BAD practice consider excluding its dependency and providing your own version of that dependency. This makes your build reproducible at any time. Please improve your answer buy removing your suggestion to use + in the dependency version. Jul 2, 2014 at 15:21
  • 1
    What @DanieleSegato said. Do not recommend dynamic versioning ever. It's bad practices. Jul 2, 2014 at 18:39
69

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.

4
  • Good catch! none of my v7 had the version on them either. Jun 27, 2014 at 1:54
  • and also the same thing for support v13 )
    – Defuera
    Jul 1, 2014 at 21:41
  • 1
    I had a mismatch of appcompat_v7 too, buildToolsVersion '20.0.0' in my android{} and compile 'com.android.support:appcompat-v7:20.0+' in my dependencies {} was not the same, so I made them the same (as shown here).
    – Azurespot
    Jul 6, 2014 at 7:48
  • 1
    It is a bad practice to use + identifier for future versions. Specify the exact version. I suggest to update the 'com.android.support:appcompat-v7:19.+' to this 'com.android.support:appcompat-v7:19.0.0' or which is the latest one. If you still face issues try updating support library from SDK manager.
    – sud007
    Apr 22, 2015 at 10:58
56

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

4
  • In my case I also had to remove the appcompat-v7 equivalent.
    – eipipuz
    Jul 1, 2014 at 21:24
  • 2
    Yes do not provide solution 2 as an option. Proper dependency management (using the right version), or using resolution strategy is the right solution. Editing the maven repo is only delaying the problem until a new repo is released. Jul 2, 2014 at 18:38
  • Solution 1 + 3 saved my life :)
    – Climbatize
    Aug 10, 2014 at 19:00
  • 2
    First option works! I would suggest you to add some details about why this to be done. Nov 11, 2014 at 15:10
25
<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

2
11

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

1
  • Thanks! Easier than putting exclude in every dependency :)
    – Sloy
    Aug 3, 2014 at 10:43
8

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.+'.
0
8

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'
}
0
7

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.

5
  • Does this resolve the actual problem? No. It only works like that, but with cordova run android it fails. Aug 28, 2017 at 13:36
  • @lonut do you know what actual problem is ?
    – ProllyGeek
    Aug 28, 2017 at 14:10
  • In my case the problem is a plugin I'm using called cordova-plugin-facebook4. Unistalling it makes cordova run android work just fine. Unfortunately I didn't found any solution to this anywhere. I manually tried to add the minSdkVersion myself in the AndroidManifest but is being overwritten. Still trying to figure it out. Aug 28, 2017 at 14:52
  • @lonut I am using same plugin in some app I am working on, let me know if I can help. However you need to review the build.gradle file, maybe if you provide extra info I can help.
    – ProllyGeek
    Aug 28, 2017 at 16:12
  • I finally solved it by changing the minSdk version to 15 in config.xml. The line: <preference name="android-minSdkVersion" value="14" />. This way the AndroidManifest file is being updated also with the new version. Aug 29, 2017 at 7:30
6

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'
}
1
  • it;s not a code. you need to make this change in your build.gradle file.
    – min2bro
    Sep 17, 2014 at 13:46
6

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.

1
  • This does seem to be the fundamental issue: "wherever you see 'com.android.support:support'" ... "make sure you have the up-to-date value" That's about the size of it!
    – Fattie
    Oct 5, 2014 at 13:46
5

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.+'
}
1
  • 1
    I can't believe it. None of the other answers above worked for me, except this one. Thank you!!! Note, I had to change both my v4 and v7 support files to the :20.+.
    – Azurespot
    Jul 22, 2014 at 7:10
5
compile('com.android.support:support-v4:19.1.0'){
    force = true
}

Helped me, taken from here

4

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" />
4

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.

1
  • 3
    remember to add: xmlns:tools="http://schemas.android.com/tools" in the <manifest>-tag
    – seb
    Aug 24, 2014 at 16:19
3

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

3

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

0
3

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.

1

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"
    }
0

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".

0

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'
0

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

0

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:+'
}
0

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

0

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.

1
  • I have changed "L" and restarted android studio but getting same issue when build project (ctrl+f9) Sep 17, 2014 at 12:14
0

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.+

0

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

0

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.

0

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.

2
  • A link to a solution is welcome, but you should ensure your answer is also useful without it. It's better to add context around the link and describe the most relevant part of the tutorial you're linking to in case the target page is unavailable.
    – Joey
    Jul 30, 2019 at 22:20
  • Nice to hear from you #Joey. Let me add some extra description. Thanks. Jul 31, 2019 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.