Gradle构建错误。“minsdkversion 14不能与在库中声明的版本不同”?

时间:2022-01-27 20:49:23

Hi everyone I am new to android developing.I download the latest version of android studio 1.3.2 yesterday.But when I start a new project for testing, gradle give me an error. My gradle is

大家好,我是android开发的新手。我昨天下载了最新版的android studio 1.3.2。但是当我开始一个新的测试项目时,gradle给了我一个错误。我的它是

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.example.niyamat.testing3"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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

}

The error is

错误的是

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]   C:\Users\Niyamat\Documents\Testing3\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0-rc1\AndroidManifest.xml

I know there are some question about the same error but I didn't find any good solution. So please someone help me?

我知道有一些关于相同错误的问题,但我没有找到任何好的解决方案。有人帮我吗?

4 个解决方案

#1


0  

It is your issue.

这是你的问题。

uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]

uses-sdk:minSdkVersion 15不能与在库中声明的版本不同[com.android.support:appcompat-v7:21.0 -rc1]

It is quite strange that you have in your sdk folder the preview version of appcompat 21. This version was published with the lollipop preview (api-L) and had the minSdk = L. It is the reason of your issue (because you have minSdkVersion 15)

很奇怪,你的sdk文件夹里有appcompat 21的预览版。这个版本是用lollipop预览版(api-L)发布的,并有minSdk = l,这是您问题的原因(因为您有minSdkVersion 15)

You should not have this folder in your sdk. Check with the SDK Manager if it is updated.

您的sdk中不应该有这个文件夹。如果有更新,请与SDK管理器进行检查。

Then you can modify your build.gradle removing the +.

然后您可以修改您的构建。gradle删除+。

Support libraries v21

支持库v21

compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.3'

Support libraries v22 (require compileSdkVersion 22)

支持库v22(需要编译版本22)

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.1'

Support libraries v23 (require compileSdkVersion 23)

支持库v23(需要编译版本23)

compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'

#2


1  

Whats your Logcat Throws

 Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]

What should you Do

你该怎么做

  1. Remove minSdkVersion version from Manifest .You already declare it in your build.gradle .
  2. 从清单中删除minSdkVersion版本。您已经在构建中声明了它。gradle。
  3. Use this compileSdkVersion 21 buildToolsVersion '21.1.2' instead yours.
  4. 使用这个编译版本21 buildToolsVersion '21.1.2'代替您的。
  5. Compile compile 'com.android.support:appcompat-v7:21.0.1'
  6. 编译编译“com.android.support:appcompat-v7:21.0.1”

First of all remove this line from your Manifest .

首先从清单中删除这一行。

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />

Finally

最后

    apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.niyamat.testing3"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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

}

#3


0  

Seems you have a previous version of the app compat into your lib folder specific for android L.

似乎你有一个之前版本的应用程序压缩到你的lib文件夹,具体的android L。

Also you should set the version for compileSdkVersion, buildToolVersion, targetSdkVersion and the appcompat-v7 to be the same.

同样,您应该为编译版本、buildToolVersion、targetSdkVersion和appcompat-v7设置版本。

In your case, the buildToolVersion should be "21.1.2".

在您的例子中,buildToolVersion应该是“21.1.2”。

#4


0  

Basically, this is the reason why android studio complains / suggests NOT using .+ in your compiles.

基本上,这就是android studio抱怨/建议不使用的原因。

compile 'com.android.support:appcompat-v7:21.+'

It forces compile with absolute last version of appcompat 21 which is com.android.support:appcompat-v7:21.0.0-rc1 (as you can see from error you got). That version does not allow minSdkVersion 15 - it's made for Lollipop. Change your compile appcompat to version number that does allow minSdkVersion 15 to solve the issue.

它使用appcompat 21的绝对最后一个版本进行编译,它是com.android.support:appcompat-v7:21.0 -rc1(您可以从错误中看到)。这个版本不允许minSdkVersion 15 -它是为棒棒糖做的。将您的编译appcompat更改为版本号,允许minSdkVersion 15解决这个问题。

#1


0  

It is your issue.

这是你的问题。

uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]

uses-sdk:minSdkVersion 15不能与在库中声明的版本不同[com.android.support:appcompat-v7:21.0 -rc1]

It is quite strange that you have in your sdk folder the preview version of appcompat 21. This version was published with the lollipop preview (api-L) and had the minSdk = L. It is the reason of your issue (because you have minSdkVersion 15)

很奇怪,你的sdk文件夹里有appcompat 21的预览版。这个版本是用lollipop预览版(api-L)发布的,并有minSdk = l,这是您问题的原因(因为您有minSdkVersion 15)

You should not have this folder in your sdk. Check with the SDK Manager if it is updated.

您的sdk中不应该有这个文件夹。如果有更新,请与SDK管理器进行检查。

Then you can modify your build.gradle removing the +.

然后您可以修改您的构建。gradle删除+。

Support libraries v21

支持库v21

compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.3'

Support libraries v22 (require compileSdkVersion 22)

支持库v22(需要编译版本22)

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.1'

Support libraries v23 (require compileSdkVersion 23)

支持库v23(需要编译版本23)

compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'

#2


1  

Whats your Logcat Throws

 Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]

What should you Do

你该怎么做

  1. Remove minSdkVersion version from Manifest .You already declare it in your build.gradle .
  2. 从清单中删除minSdkVersion版本。您已经在构建中声明了它。gradle。
  3. Use this compileSdkVersion 21 buildToolsVersion '21.1.2' instead yours.
  4. 使用这个编译版本21 buildToolsVersion '21.1.2'代替您的。
  5. Compile compile 'com.android.support:appcompat-v7:21.0.1'
  6. 编译编译“com.android.support:appcompat-v7:21.0.1”

First of all remove this line from your Manifest .

首先从清单中删除这一行。

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />

Finally

最后

    apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.example.niyamat.testing3"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

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

}

#3


0  

Seems you have a previous version of the app compat into your lib folder specific for android L.

似乎你有一个之前版本的应用程序压缩到你的lib文件夹,具体的android L。

Also you should set the version for compileSdkVersion, buildToolVersion, targetSdkVersion and the appcompat-v7 to be the same.

同样,您应该为编译版本、buildToolVersion、targetSdkVersion和appcompat-v7设置版本。

In your case, the buildToolVersion should be "21.1.2".

在您的例子中,buildToolVersion应该是“21.1.2”。

#4


0  

Basically, this is the reason why android studio complains / suggests NOT using .+ in your compiles.

基本上,这就是android studio抱怨/建议不使用的原因。

compile 'com.android.support:appcompat-v7:21.+'

It forces compile with absolute last version of appcompat 21 which is com.android.support:appcompat-v7:21.0.0-rc1 (as you can see from error you got). That version does not allow minSdkVersion 15 - it's made for Lollipop. Change your compile appcompat to version number that does allow minSdkVersion 15 to solve the issue.

它使用appcompat 21的绝对最后一个版本进行编译,它是com.android.support:appcompat-v7:21.0 -rc1(您可以从错误中看到)。这个版本不允许minSdkVersion 15 -它是为棒棒糖做的。将您的编译appcompat更改为版本号,允许minSdkVersion 15解决这个问题。