Error:(31, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library

Error:(31, 5) uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library

我正在尝试使用 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.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.9.1\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="it.gmariotti.cardslib.library" to force usage

我试过把card lib的版本改成stable,但是我一直报同样的错误

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 .所以非常感谢你的帮助。

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

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

可以找到更多信息 here

您应该像这样更改 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。