代码之家  ›  专栏  ›  技术社区  ›  Dave Chambers

尝试向Kotlin项目添加木材会导致多个“无法解决…”渐变错误的依赖关系。

  •  0
  • Dave Chambers  · 技术社区  · 7 年前

    我已经向我的Kotlin项目添加了 implementation'com.jakewharton.timber:timber:4.7.1'.

    配置'compile'已过时,并已替换为'implementation'和'api'。
    将于2018年底拆除。有关详细信息,请参阅:http://d.android.com/r/tools/update-dependency-configurations.html
    
    
    无法解析对“:app@debug/compileClassPath”的依赖关系:无法解析com.jakewharton.timber:timber:4.7.1。
    打开文件
    显示细节
    
    
    无法解析对“:app@debugandroidtest/compileClassPath”的依赖关系:无法解析com.jakewharton.timber:timber:4.7.1。
    打开文件
    显示细节
    
    
    无法解析对“:app@debugunittest/compileClassPath”的依赖关系:无法解析com.jakewharton.timber:timber:4.7.1。
    打开文件
    显示细节
    
    
    无法解析“:app@release/compileClassPath”的依赖项:无法解析com.jakewharton.timber:timber:4.7.1。
    打开文件
    显示细节
    
    
    无法解析对“:app@releaseUnitTest/compileClassPath”的依赖关系:无法解析com.jakewharton.timber:timber:4.7.1。
    打开文件
    显示细节
    < /代码> 
    
    

    奇怪的是,虽然我可以看到它以渐变同步的方式下载:

    我还尝试添加了timberkt但得到了类似的错误。

    我的整个app/build.gradlefile看起来如下:

    应用插件:“com.android.application” 应用插件:“Kotlin Android” 应用插件:“Kotlin Android扩展” 应用插件:“Kotlinx序列化” 安卓{ 编译dkversion 26 Debug TCONFIG { 应用程序ID“uk.co.davechambers.pegboard” 目标版本26 Minsdk版本21 版本代码1 版本名“1.0” TestInstrumentRunner“android.support.test.runner.androidjunitrunner” vectorDrawables.useSupportLibrary=真 } 构建类型{ 释放{ MinifyEnabled错误 proguardfiles getdefaultproguardfile('proguard-android.txt'),'proguard rules.pro' } } } 储存库{ GoGoE() JCSENT() maven url“https://kotlin.bintray.com/kotlinx” } 依赖项{ 实现文件树(dir:'libs',include:'*.jar']) androidTestImplementation('com.android.support.test.espresso:espresso core:2.2.2','{ 排除组:“com.android.support”,模块:“支持注释” }) 实现“org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version” 实现“com.android.support:appcompat-v7:26.0.0-beta2” “JUnit:JUnit:4.12”测试实施 实现“com.android.support:design:26.0.0-beta2” 实现“com.android.support.constraint:constraint layout:1.0.2” 实现“com.android.support:support vector drawable:26.0.0-beta2” 实现“com.jakewharton.timber:timber:4.7.1” 编译“org.jetbrains.anko:anko:$anko-version” 编译“org.jetbrains.kotlin:kotlin stdlib:$kotlin_version” 编译“org.jetbrains.kotlinx:kotlinx序列化运行时:$serialization_版本” } 科特林{ 实验{ 协程“启用” } } androidextensions公司{ 实验=真 } < /代码>

    显然我做错了什么。有人能给我指个方向吗?

    奇怪的是,虽然我可以看到它以渐变同步的方式下载:

    enter image description here

    我也试着补充 timberkt 但也有类似的错误。

    我的整个 app/build.gradle 文件如下:

    apply plugin: 'com.android.application'
    
    apply plugin: 'kotlin-android'
    
    apply plugin: 'kotlin-android-extensions'
    
    apply plugin: 'kotlinx-serialization'
    
    android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "uk.co.davechambers.pegboard"
        targetSdkVersion 26
        minSdkVersion 21
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary= true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    repositories {
    google()
    jcenter()
        maven { url "https://kotlin.bintray.com/kotlinx" }
       }
    
    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:design:26.0.0-beta2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-vector-drawable:26.0.0-beta2'
    implementation 'com.jakewharton.timber:timber:4.7.1'
    compile "org.jetbrains.anko:anko:$anko_version"
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
    }
    
     kotlin {
    experimental {
        coroutines "enable"
    }
      }
    
    androidExtensions {
    experimental = true
    }
    

    显然我做错了什么。有人能给我指个方向吗?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Dave Chambers    7 年前

    我添加了一个额外的maven url到 build.gradle (Module: app) :

    repositories {
        google()
        jcenter()
        maven { url "https://kotlin.bintray.com/kotlinx" }
        maven { url "http://jcenter.bintray.com"}
    }
    

    并且 build.gradle (Project: projectName) :

    buildscript {
        ext.kotlin_version = '1.2.40'
        ext.anko_version = '0.10.5'
        ext.serialization_version = '0.4.1'
        repositories {
            google()
            jcenter()
            maven { url "https://kotlin.bintray.com/kotlinx" }
            maven { url "http://jcenter.bintray.com"}
        }
    .....
    

    之后,一切都正常了。

    推荐文章