Trying to add timber to Kotlin project results in multiple 'Unable to resolve dependency for...' Gradle errors

1.3k views Asked by At

I have added implementation 'com.jakewharton.timber:timber:4.7.1' to my Kotlin project and now I get the following Gradle errors:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.jakewharton.timber:timber:4.7.1.
Open File
Show Details

Strangely though I can see it downloading as Gradle syncs:

enter image description here

I also tried adding timberkt but got a similar error.

My whole app/build.gradle file looks like this:

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
}

Clearly I'm doing something wrong. Can anybody point me in the right direction?

1

There are 1 answers

0
Dave Chambers On BEST ANSWER

I added an additional Maven url to build.gradle (Module: app):

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

and to 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"}
    }
.....

After that, everything worked.