【问题标题】:Error:(31, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library错误:(31, 5) uses-sdk:minSdkVersion 9 不能小于库中声明的版本 14
【发布时间】:2015-03-17 20:32:11
【问题描述】:

我正在尝试使用 Gabriele Mariotti 卡片库,来自 github 使用 https://github.com/gabrielemariotti/cardslib

目前我正在使用 Android Studio,因此我已将依赖项添加到我的构建 gradle 文件中,如文档中所述。

这就是我的 gradle 文件的样子

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.1"

    defaultConfig {
        applicationId "com.vt"
        minSdkVersion 9
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':facebookSDK')
    compile project(':addslidepanel30')
    compile 'com.android.support:support-v4:21.0.1'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile files('libs/android-support-v7-palette.jar')
    compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
    compile files('libs/volley.jar')

    //Core
    compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.1'

    //Optional for built-in cards
    compile 'com.github.gabrielemariotti.cards:cardslib-cards:2.0.1'

    //Optional for RecyclerView
    compile 'com.github.gabrielemariotti.cards:cardslib-recyclerview:2.0.1'

    //Optional for staggered grid view
    compile 'com.github.gabrielemariotti.cards:cardslib-extra-staggeredgrid:2.0.1'

    //Optional for drag and drop
    compile 'com.github.gabrielemariotti.cards:cardslib-extra-dragdrop:2.0.1'

    //Optional for twoway  (coming soon)
    //compile 'com.github.gabrielemariotti.cards:cardslib-extra-twoway:2.0.1'
}

但我不断收到此消息错误

Error:(31, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library C:\Users\SAM-PC\AndroidStudioProjects\vt1.3.0.0 newDB\vt1300newDB\build\intermediates\exploded-aar\com.github.gabrielemariotti.cards\library\1.9.1\AndroidManifest.xml
Error:(31, 5) Execution failed for task ':vt1300newDB:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library C:\Users\SAM-PC\AndroidStudioProjects\vt1.3.0.0 newDB\vt1300newDB\build\intermediates\exploded-aar\com.github.gabrielemariotti.cards\library\1.9.1\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="it.gmariotti.cardslib.library" to force usage

我尝试将卡库的版本更改为稳定版,但我一直收到同样的错误

dependencies {
    //Core card library
    compile 'com.github.gabrielemariotti.cards:library:1.9.1'

    //Extra card library, it is required only if you want to use integrations with other libraries
    compile 'com.github.gabrielemariotti.cards:library-extra:1.9.1'
}

PS:我是 Android Studio 新手,我的项目在 Eclipse 中运行良好,但我正在尝试迁移到 Android Studio,因为它是 google 推荐的。所以非常感谢您的帮助。

【问题讨论】:

    标签: android android-studio gradle dependencies


    【解决方案1】:

    将以下内容添加到您的清单中:

    <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="14"
              tools:overrideLibrary="it.gmariotti.cardslib.library"/>
    

    更多信息可以在here找到。

    【讨论】:

    • 谢谢,我已经把 minSdk 改成了 9 ,它可以工作了
    【解决方案2】:

    您应该像这样更改您的AndroidManifest.xml

    <uses-sdk android:targetSdkVersion="22" android:minSdkVersion="14"
          tools:overrideLibrary="it.gmariotti.cardslib.library"/>
    

    你需要把你项目的minSdkVersion改成14或者it.gmariotti.cardslib.library改成9。因为导入库的minSdkVersion是14。

    【讨论】:

      猜你喜欢
      • 2018-01-22
      • 1970-01-01
      • 1970-01-01
      • 2016-09-14
      • 2021-04-10
      • 1970-01-01
      • 2021-05-15
      • 2021-03-14
      • 2017-12-18
      相关资源
      最近更新 更多