Manifest merger failed : uses-sdk:minSdkVersion 14
Asked Answered
D

28

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
Dumbfound answered 26/6, 2014 at 19:0 Comment(4)
I am having same error Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 19 declared in library com.android.support:support-v4:21.0.0-rc1Devorahdevore
I'm getting the same exception minSdkVersion 15 cannot be smaller than version 15. The SDK Build tools has been updated so I guess its a bug in Android Studio and the new Build toolsTintype
It seems to be a bug: code.google.com/p/android/issues/detail?id=72430 The fix for now is to comment out a line in the maven-metadata.xmlShieh
possible duplicate of Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smallerScaramouch
D
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!

Dumbfound answered 26/6, 2014 at 19:13 Comment(12)
What about a library compiled from Maven ? How to exclude the "old" dependancy ?Crepuscular
@Crepuscular not sure there's a way around that. Somebody else will have to comment on that. I'd suggest opening a pull request and/or issue if the project is open source.Dumbfound
@Crepuscular compile("blah:blah:bla") {exclude group: 'com.android.support', module: 'support-v4'}Disarmament
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/…Donne
In my case I had to remove it from local maven as gauravsapiens commented.Radiotelegraph
worked, thanks. found this as well google-android-studio.blogspot.co.uk/2013/10/…Excrete
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.Futility
What @DanieleSegato said. Do not recommend dynamic versioning ever. It's bad practices.Pyuria
@XavierDucrohet @DanieleSegato, I updated the answer. What should the v7 support library version be? com.android.support:cardview-v7:20 or variations I tried don't seem to work. I changed the previous to 20.0.0 (which seems to work fine).Dumbfound
@Dumbfound those libraries are only available in 21.0.0-rc1 so you should put that. When we update to rc2 or the final version you'll need to manually update it but that's better than never doing it, forgetting about it and later be hit when we release 22-rc1 which breaks the project somehow.Pyuria
@DanieleSegato said this right. It's bad practice to use '+' as identifier for future versions. I have been using compile 'com.android.support:support-v4:21.0.0' and this fixed the issue. But do not forget to update the support library version from SDK manager.Edrick
compile 'com.android.support:cardview-v7:22.2.0' this is the compatible cardviewFixture
C
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.

Cheke answered 26/6, 2014 at 23:15 Comment(4)
Good catch! none of my v7 had the version on them either.Heaton
and also the same thing for support v13 )Franklinfranklinite
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).Housen
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.Edrick
C
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

Chesterchesterfield answered 27/6, 2014 at 12:48 Comment(4)
In my case I also had to remove the appcompat-v7 equivalent.Radiotelegraph
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.Pyuria
Solution 1 + 3 saved my life :)Shwa
First option works! I would suggest you to add some details about why this to be done.Triceps
S
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

Sainthood answered 17/11, 2014 at 7:12 Comment(2)
As outlined here: tools.android.com/tech-docs/new-build-system/user-guide/…Humerus
Thank you @Sainthood , upvoted for saving my day :)Rosati
P
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

Provinciality answered 2/7, 2014 at 13:37 Comment(1)
Thanks! Easier than putting exclude in every dependency :)Mastery
C
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'
}
Collation answered 2/7, 2014 at 1:50 Comment(0)
E
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.+'.
Embitter answered 5/7, 2014 at 21:17 Comment(0)
C
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.

Calefacient answered 28/4, 2016 at 1:47 Comment(5)
Does this resolve the actual problem? No. It only works like that, but with cordova run android it fails.Monticule
@lonut do you know what actual problem is ?Calefacient
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.Monticule
@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.Calefacient
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.Monticule
C
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.

Consortium answered 23/7, 2014 at 16:52 Comment(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!Agglomeration
M
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'
}
Muldrow answered 17/8, 2014 at 16:47 Comment(1)
it;s not a code. you need to make this change in your build.gradle file.Muldrow
E
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.+'
}
Exasperate answered 3/7, 2014 at 11:27 Comment(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.+.Housen
U
5
compile('com.android.support:support-v4:19.1.0'){
    force = true
}

Helped me, taken from here

Unused answered 25/9, 2014 at 6:50 Comment(0)
I
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" />
Illusionist answered 1/7, 2014 at 13:52 Comment(0)
Q
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.

Queri answered 22/7, 2014 at 17:16 Comment(1)
remember to add: xmlns:tools="http://schemas.android.com/tools" in the <manifest>-tagHannus
C
3

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

Collusion answered 27/6, 2014 at 12:55 Comment(0)
N
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

Nicolella answered 28/6, 2014 at 6:58 Comment(0)
B
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.

Beatup answered 21/6, 2018 at 7:16 Comment(0)
F
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"
    }
Foil answered 17/7, 2019 at 10:35 Comment(0)
M
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".

Morville answered 1/7, 2014 at 8:1 Comment(0)
H
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'
Humerus answered 7/7, 2014 at 15:52 Comment(0)
G
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

Greed answered 21/8, 2014 at 18:45 Comment(0)
H
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.

Happiness answered 8/9, 2014 at 21:21 Comment(1)
I have changed "L" and restarted android studio but getting same issue when build project (ctrl+f9)Deland
P
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:+'
}
Porky answered 1/4, 2015 at 7:17 Comment(0)
R
0

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

Russophobe answered 6/4, 2015 at 14:45 Comment(0)
M
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.+

Mesothorium answered 18/9, 2015 at 18:52 Comment(0)
R
0

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

Rabbinate answered 1/2, 2019 at 18:26 Comment(0)
E
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.

Emery answered 19/5, 2019 at 7:15 Comment(0)
S
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.

Sennar answered 30/7, 2019 at 21:26 Comment(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.Plaintive
Nice to hear from you #Joey. Let me add some extra description. Thanks.Sennar

© 2022 - 2024 — McMap. All rights reserved.