根据 compileSDKversion 选择合适的支持库版本

Choosing a right version of support library base on compileSDKversion

我的 compileSDKversion 是 26,所以我想在应用 build.gradel 中添加一些支持库,例如 implementation 'com.android.support:card-v7:26.x.x'。 如何为我当前的 compileSDK version 选择正确的版本?

我刚刚做了 "try and fail"。我的意思是,我输入 x=1,然后输入 运行 "sync project with gradle",然后等待 IDE 通知它运行正常。但我不知道我应该使用哪个版本。我搜索了一下,发现有人根据compileSDKversion告诉支持库的版本,应该使用最后的'compileSDKVersion',但这并不能解决我的问题。

https://developer.android.com/topic/libraries/support-library/setup 可以帮助您设置 support librairy

我认为你的情况 cardcardview。因为我在尝试同步时没有找到 card

这是我为 sdk 26 建议的示例

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        ...
        targetSdkVersion 26
        ...
    }
    ...
}

dependencies {
    ...
    implementation 'com.android.support:cardview-v7:26.1.0'
    ...
}