Kotlin项目中来自Gradle的未解决依赖项

时间:2018-12-28 09:43:22

标签: android gradle android-gradle

我在项目下有以下build.gradle文件:

buildscript {
    ext.kotlin_version = '1.3.11'
    ext.gradle_version = '3.2.1'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$gradle_version"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我在app module下的build.gradle:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

androidExtensions {
    experimental = true
}

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "com.sample.android.tmdb"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        buildConfigField "String", "TMDB_API_KEY", "\"${getProperty("local.properties", "tmdb_api_key")}\""
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }
}

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

    // Support libraries
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation "com.android.support:palette-v7:$supportLibraryVersion"
    implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'

    // Architecture components
    implementation "android.arch.paging:runtime:$pagingVersion"
    implementation "android.arch.lifecycle:runtime:$lifecycleVersion"
    implementation "android.arch.lifecycle:extensions:$lifecycleVersion"

    // Gson
    implementation 'com.google.code.gson:gson:2.8.5'

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
    implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"

    // Dagger
    implementation "com.google.dagger:dagger:$daggerVersion"
    kapt "com.google.dagger:dagger-compiler:$daggerVersion"
    implementation "com.google.dagger:dagger-android:$daggerVersion"
    implementation "com.google.dagger:dagger-android-support:$daggerVersion"
    kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

    //Android RX
    implementation "io.reactivex.rxjava2:rxjava:$rxjavaVersion"
    implementation "io.reactivex.rxjava2:rxandroid:$rxandroidVersion"

    // Network
    implementation 'com.squareup.okhttp3:logging-interceptor:3.12.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation "com.github.bumptech.glide:glide:$glideVersion"
    kapt "com.github.bumptech.glide:compiler:$glideVersion"

    // Timber
    implementation 'com.jakewharton.timber:timber:4.7.1'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

def getProperty(String filename, String propName) {
    def propsFile = rootProject.file(filename)
    if (propsFile.exists()) {
        def props = new Properties()
        props.load(new FileInputStream(propsFile))
        if (props[propName] != null) {
            return props[propName]
        } else {
            print("No such property " + propName + " in file " + filename)
        }
    } else {
        print(filename + " does not exist!")
    }
}

构建项目时出现以下错误:

Failed to resolve: adapters 
Failed to resolve: library  
Failed to resolve: runtime  
Failed to resolve: palette-v7   
Failed to resolve: common

我该如何解决?

可以在以下位置找到项目:https://github.com/Ali-Rezaei/TMDb-Paging

附录:

我只是将4.6的版本更改为4.4

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

然后gradle_version = '3.1.4'可以正常工作。

0 个答案:

没有答案