Android Studio gradle不编译指定的版本

Tha*_*zan 23 android gradle android-studio build.gradle android-gradle-plugin

我已经开发了这个小项目好几天了但是今天突然间,Android Studio开始给我这个错误

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
Run Code Online (Sandbox Code Playgroud)

我明白这是因为它正在尝试编译Android-L库.我想要它编译的版本是旧版本,但它不会.无论我输入哪个版本,它都会一直给我上述错误.这是依赖项.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.android.support:support-v4:20.+'
}
Run Code Online (Sandbox Code Playgroud)

UPDATE

我刚刚安装了Android Studio Beta并将我的依赖项更改为下面的Eugen建议.但是,无论我指定哪个版本的appcompat支持版本,同步项目都会产生相同的错误.它每次同步时都会出现此错误

uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:support-v4:21.0.0-rc1
Run Code Online (Sandbox Code Playgroud)

我更新的依赖项

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.android.support:support-v4:19.+'
}
Run Code Online (Sandbox Code Playgroud)

更新2

我认为我没有正确理解Android Studio的依赖系统.我刚从依赖项中删除了appcompat和support,它仍然给了我同样的错误.我是否必须从某处删除最初包含的库?

的build.gradle

*注意 - 我再次添加了这两个库并尝试同步,以防万一.但没有变化.

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'
}
Run Code Online (Sandbox Code Playgroud)

顶级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()
    }
}
Run Code Online (Sandbox Code Playgroud)

Tal*_*tle 43

更新:找到了我的案例的真正修复.通过在以下操作中执行此操作,确保您的所有依赖项都没有默认包括support-v4 r21 build.gradle:

compile("com.blahblah:blah:123") {
    exclude group: 'com.android.support', module:'support-v4'
}
Run Code Online (Sandbox Code Playgroud)

您可以将exclude所有库添加到所有库中,然后逐个删除,直到找出哪个库正在拉入support-v4并向您提供错误.并留exclude在那一个.


此处提交了一个新错误:https://code.google.com/p/android/issues/detail?id = 72430

假设您使用的是支持存储库,则解决方法是注释或删除该行

<version>21.0.0-rc1</version>
Run Code Online (Sandbox Code Playgroud)

在当地的Maven repo列表文件中 <android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml


Gab*_*tti 24

使用以下更新:

compile 'com.android.support:support-v4:20.+'
Run Code Online (Sandbox Code Playgroud)

要么

compile 'com.android.support:support-v4:+'
Run Code Online (Sandbox Code Playgroud)

您正在使用L-preview中的支持库.

这些支持库正在声明minSdkVersion L.

你必须强迫它minSdkVersion为'L'(检查文档)

这是因为这些API不是最终的.这是一种阻止在最终API 21设备上安装应用程序或使用支持lib 21-r1在商店上发布应用程序的方法.

运用

compile 'com.android.support:support-v4:19.1.0'
Run Code Online (Sandbox Code Playgroud)

您正在使用"旧"支持库19.1.0.


小智 24

我遇到了同样的问题,因为我的一个依赖项指定了'support-v7:+'作为依赖项.我能够使用它来追踪这个gradle dependencies

Gradle提供了一种强制解析特定版本的方法.我最终得到了这个build.grade:

compile('com.android.support:appcompat-v7:19.1.0') {
    // really use 19.1.0 even if something else resolves higher
    force = true 
}
Run Code Online (Sandbox Code Playgroud)


For*_*uru 9

compile('com.android.support:support-v4:19.1.0'){
    force = true
}
Run Code Online (Sandbox Code Playgroud)

这对我有用