0

我正在尝试使用 android 支持库制作一个应用程序,所以如果我开始一个具有基本活动的新项目,然后使用依赖项菜单添加 android 支持库,我会收到此错误:

This support library should not use a different version (24) than the `compileSdkVersion` (23)

这是我的 gradle 文件的样子:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.example.moore.criminalintent"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.android.support:support-v4:24.0.0'
}

除了创建项目和添加依赖项之外,我没有触及任何其他设置。任何解决此问题的帮助将不胜感激。

4

3 回答 3

3

由于您使用的是支持库 v24

compile 'com.android.support:support-v4:24.0.0'

必须使用API 24进行编译。利用:

compileSdkVersion 24
于 2016-06-23T08:15:19.660 回答
0

如果您使用的是 compile SDK version 24,那么您应该将其用作

编译'com.android.support:support-v4:24.0.0'

于 2016-09-15T08:55:46.303 回答
0

更改compile 'com.android.support:support-v4:24.0.0'compile 'com.android.support:support-v4:23+'(并可选择提供子版本。加号表示将使用 23.something 的最新版本)。

此错误是因为您正在针对 API 版本 23 (android M) 进行编译,因此您无法使用支持库版本 24。据我了解,支持库的版本 24 是针对最近发布的 Android N 开发者预览版。

或者,您可以将编译 SDK 版本粗略增加到 24。

于 2016-06-23T00:22:06.933 回答