无法添加 Gradle 依赖项

Unable to add Gradle Dependency

我正在尝试将此依赖项添加到 gradle,但我收到以下关于其他依赖项的错误,这些依赖项是我一开始没有添加的。

错误:

我要添加的依赖项是 com.wdullaer:materialdatetimepicker:3.1.3

build.gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.pf.datetimepicker"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.wdullaer:materialdatetimepicker:3.1.3'
}

改变你的compileSdkVersionbuildToolsVersiontargetSdkVersion

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.pf.datetimepicker"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.wdullaer:materialdatetimepicker:3.1.3'
}

将您的 compile 和 targetsdk 更改为 25

您没有安装最新版本的 android 支持库。只需打开 SDK 管理器并安装它们。 See the image

which I have not added in the first Place.

你确定...

查看你得到的库的源码。 https://github.com/wdullaer/MaterialDateTimePicker/blob/master/library/build.gradle

compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:support-v13:25.2.0'
compile 'com.android.support:design:25.2.0'

首先,您需要 compileSdkVersion 25 才能使它们正常工作,然后您需要允许 Android Studio "Install Repository and Sync Project" 或通过更新 SDK 管理器自行完成。