android - Gradle 构建错误 ."minsdkversion 14 cannot be different than version l declared in library"?

标签 android gradle android-gradle-plugin build.gradle android-appcompat

大家好,我是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.+'

}

错误是
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

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

最佳答案

你的 Logcat 抛出了什么

 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]

你应该怎么做
  • 删除 minSdkVersion来自 的版本 list .您已经在 中声明了它build.gradle .
  • 使用这个compileSdkVersion 21 buildToolsVersion '21.1.2'而不是你的。
  • 编译compile 'com.android.support:appcompat-v7:21.0.1'

  • 首先从您的 中删除此行 list .
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />
    

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

    关于android - Gradle 构建错误 ."minsdkversion 14 cannot be different than version l declared in library"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32448927/

    相关文章:

    java - RecyclerView 未附加到 Adapter

    android - Eclipse 中的 Logcat 查看器令人讨厌地闪烁

    android - 对 Android 10 上的外部文件的访问权限被拒绝

    android - 无法将altbeacon库包含到新项目中

    android - 具有依赖项的Android Studio自定义gradle任务- “Could not get unknown property”

    android - 在 Android 中使用 Gmail API 发送带附件的电子邮件(execute() 挂起)

    gradle - 在Gradle中,如何在使用useTestNg时从testng-context xml中指定测试名称

    android - Android Studio无法识别SDK

    android - 从eclipse导入android studio出错

    java - 在 Gradle 中,[如何] 我们应该同时针对 Android 和 JRE?