Android Studio gradle doesn't compile the specified version
Solution 1
UPDATE: Found the real fix for my case. Make sure none of your dependencies are silently including support-v4 r21 by doing this in your build.gradle
:
compile("com.blahblah:blah:123") {
exclude group: 'com.android.support', module:'support-v4'
}
You can add the exclude
to all libraries, then remove one-by-one until you figure out which one was pulling in support-v4
and giving you the error. And leave exclude
on that one.
There is a new bug filed here: 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
<version>21.0.0-rc1</version>
in the local Maven repo listing file at <android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml
Solution 2
With the last updates, using this:
compile 'com.android.support:support-v4:20.+'
or
compile 'com.android.support:support-v4:+'
you are using the support lib in L-preview.
These support libs are declaring minSdkVersion L
.
You have to force the minSdkVersion
to be 'L' (check the doc)
This is because these APIs are not final. It is a way to prevent installing the apps on a final API 21 device or publishing it on the store using support lib 21-r1.
Using
compile 'com.android.support:support-v4:19.1.0'
you are using the "old" support library 19.1.0.
Solution 3
I had the same issue as one of my dependencies had specified 'support-v7:+' as a dependency. I was able to track this down using gradle dependencies
Gradle provides a way to force resolution to a specific version. I ended up having this in my build.grade
:
compile('com.android.support:appcompat-v7:19.1.0') {
// really use 19.1.0 even if something else resolves higher
force = true
}
Solution 4
compile('com.android.support:support-v4:19.1.0'){
force = true
}
This worked for me
Solution 5
That is correct. The new support library is not compatible (yet) with old Android versions.
Change your gradle to:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.1.+'
compile 'com.android.support:support-v4:19.1.+'
}
I hope your still have something like this:
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
Related videos on Youtube
Comments
-
Thahzan over 4 years
I've been developing this small project for some days now but suddenly today, Android Studio started to give me this error
Error:Execution failed for task ':app:processDebugManifest'. > Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version 14 declared in library com.android.support:support-v4:21.0.0-rc1
I understood that it is because it's trying to compile the library of Android-L. The version I want it to compile is the old version but it won't. It keeps giving me the above error no matter which version I enter. Here is the dependencies.
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:20.+' compile 'com.android.support:support-v4:20.+' }
UPDATE
I just installed Android Studio Beta and changed my dependencies to the one Eugen suggested below. But syncing the project gives the same error no matter which version of appcompat, support version I specify. It gives this error every single time I sync
uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
My updated dependencies
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:19.+' compile 'com.android.support:support-v4:19.+' }
UPDATE 2
I don't think I understand the dependencies system of Android Studio correctly. I just removed both the appcompat and support from the dependencies and it still gives me the same error. Do I have to remove the initially included libraries from somewhere?
build.gradle
*note - I added those two libraries back in again and tried syncing, just in case. But no chenges.
apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion "19.1.0" defaultConfig { applicationId "taz.starz.footynews" minSdkVersion 14 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:19.+' compile 'com.android.support:support-v4:19.+' compile project(':ParallaxScroll') compile files('src/main/libs/Header2ActionBar-0.2.1.jar') compile 'com.arasthel:gnavdrawer-library:+' compile 'com.koushikdutta.ion:ion:1.2.4' }
Top level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.12.+' } } allprojects { repositories { mavenCentral() } }
-
Eugen Martynov almost 10 yearsIt looks like you have multimodal project. What id your parent build.gradle?
-
Thahzan almost 10 yearsYou mean the top level build.gradle file?
-
Eugen Martynov almost 10 yearsWhat are dependencies for parallaxscroll project?
-
Eugen Martynov almost 10 yearsYes, top level build.gradle
-
Thahzan almost 10 yearsIt's build.gradle file doesn't contain any dependencies and there's no .jar files either. So I'm assuming it doesn't have any dependencies?
-
Thahzan almost 10 yearsI added the parent build.gradle file to the OP
-
Thahzan almost 10 yearsI found
support_annotations_21_0_0_rc1.xml
andsupport_v4_21_0_0_rc1.xml
insid .idea/libraries. Shall I try deleting them? -
Thahzan almost 10 yearsI just deleted them and rebuilt the project, but the same 2 appeared back again.
-
-
Thahzan almost 10 yearsI changed it to the one you said, but it gives this (I just now installed AS Beta so it shows the error in a slightly different way) uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
-
Thahzan almost 10 yearsAnd yes, the compileSdkVersion, minSdkVersion, etc are defined correctly.
-
Eugen Martynov almost 10 yearsDid you cheange this
com.android.support:appcompat-v7:19.+
? Did you synchronized project with gradle file after? -
Thahzan almost 10 yearsAfter I changed it it requested to Sync and I did and it gave me the same error. Am I doing it wrong? Do I have to synchronise it manually?
-
Thahzan almost 10 yearsI don't think I understand the system of the Android Studio correctly. Can you see my update (2) and give me an answer Eugen?
-
Eugen Martynov almost 10 yearsCan you post your entire build.gradle file?
-
Thahzan almost 10 yearsThanks a lot dude. Solved the problem. I'm guessing after Google resolve this issue, I'll have to go back and enter it back in the file?
-
Thahzan almost 10 yearsThanks a lot for your time dude, I resolved the issue by following TalkLittle's answer.
-
Eugen Martynov almost 10 yearsGreat :) I use standalone android sdk so don't have such issue. Good to know!
-
Thahzan almost 10 yearsI understood this halfway through and tried entering
compile 'com.android.support:appcompat-v7:19.1.+'
inside dependencies but it still compiled the newest version (for some reason). TalkLittle's answer worked although I suspect it's not the best solution. -
Gabriele Mariotti almost 10 yearstry to clean the cache and resync the project
-
Emanuel Canha almost 10 yearsCommenting out that line fixes it for now.
-
IgorGanapolsky almost 10 yearscompile 'com.android.support:support-v4:20.+' doesn't seem to work.
-
akirk almost 10 yearsThe same can be caused by
appcompat-v7
, so you should also tryexclude group: 'com.android.support', module:'appcompat-v7'
when it doesn't work withsupport-v4
. -
Silvia H almost 9 yearsI'm getting the same error, and this didn't work for me.