支持图书馆的好处

Benefit of Support library

支持库的好处是事实 我可以 运行 稍后发布的功能,例如 Material 设计东西 在 android 的旧版本上。

那么为什么不能将 comileSdk 更改为例如22 以及最新版本的支持库?

我的 Gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '23.0.1'
    defaultConfig {
        applicationId "com.stack.overflow"
        minSdkVersion 22
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main { res.srcDirs = ['src/main/res', 'src/main/res/drawable/ic_action_search.png'] }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    //Google Libraries
    compile 'com.android.support:appcompat-v7:23.0.+'
    compile 'com.android.support:recyclerview-v7:23.0.+'
    compile 'com.android.support:cardview-v7:23.0.+'

}

Android studio 始终将 google 库标记为红色并且不编译。

那么为什么不能将最新的支持库与以前的 sdk 一起使用?

请更新您的targetSdkVersion 23

终于

android {
compileSdkVersion 23
buildToolsVersion "23.0.0" or '23.0.1'

defaultConfig {
    applicationId "com.stack.overflow"
    minSdkVersion 17 // Set Your Version
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}

你可以设置

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