Android Studio gradle 不编译指定版本 [英] Android Studio gradle doesn't compile the specified version

查看:45
本文介绍了Android Studio gradle 不编译指定版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我理解是因为它正在尝试编译Android-L的库.我希望它编译的版本是旧版本,但不会.无论我输入哪个版本,它都会不断给我上述错误.这是依赖项.

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

更新

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

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

我更新的依赖项

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

更新 2

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

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 - 我再次添加了这两个库并尝试同步,以防万一.但没有任何变化.

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

顶级 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()
    }
}

推荐答案

更新: 为我的案例找到了真正的解决方案.通过在 build.gradle 中执行此操作,确保您的所有依赖项都没有静默地包含 support-v4 r21:

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

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

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.

这里有一个新的错误:https://code.google.com/p/android/issues/detail?id=72430

假设您正在使用 Support Repository,解决方法是注释或删除该行

Assuming you are using the Support Repository, the workaround is to comment or remove the line

<version>21.0.0-rc1</version>

<android-sdk>/extras/android/m2repository/com/android/support-v4/maven-metadata.xml

这篇关于Android Studio gradle 不编译指定版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆