Android Studio gradle doesn't compile the specified version

三世轮回 提交于 2019-11-28 05:53:34

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

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.

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 
}
compile('com.android.support:support-v4:19.1.0'){
    force = true
}

This worked for me

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

I was getting the error:

Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 4 declared in library C:\Users\Igor\AppData\Local\Android\sdk\samples\android-21_1\legacy\ApiDemos\app\build\intermediates\exploded-aar\com.android.support\support-v4\21.0.3\AndroidManifest.xml Suggestion: use tools:overrideLibrary="android.support.v4" to force usage

Then I resolved it by putting the following in my defaultConfig gradle block:

minSdkVersion 15
targetSdkVersion 21

In Android SDK Manager install "Android Support Repository" from "extra" group. It helps me. When I added "exclude group: 'com.android.support', module:'support-v4'" build was completed, but some other errors was occured

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!