0

Failed to resolve: leakcanary-android

I got this build error after upgrading to Grade to 4.4.

I started an brand new Android Studio project and got the same error. Anyone else have the same issue?

I am on Android Studio 3.1. The following are the code of my brand new project.

build.gradle apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
}

build.gradle (top level) buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'


        // 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
}

gradle-wrapper.properites

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

The only code I added to this new project is the follow, which is instructed in https://github.com/square/leakcanary.

debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

Is this a bug in leakcanary?

ColdFire
  • 6,764
  • 6
  • 35
  • 51
Xi Wei
  • 1,669
  • 1
  • 21
  • 33

2 Answers2

1

Not quite sure. It might be a Gradle 4.4 issue because I resolved it after updating to Gradle 4.5.

Xi Wei
  • 1,669
  • 1
  • 21
  • 33
-1

The problem is the spaces

Try this

debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4' releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

  • Isn't that identical to what OP already has, in their last code block? Have you changed anything in the spacing? (It's difficult to tell: you could format your lines as code by giving them four leading spaces, or use backticks for individual sections.) And why would that specifically be a problem with Gradle 4.4 but not 4.5? – Rup Jun 21 '18 at 15:50
  • The study Rarely android has problems when compiling and more in the new version of the Gradle gets to have problems in the reading of the "implementation" "spaces" then by the time the ing. of google is working on a more stable version, the spaces can cause construction problems. – Jonathan Vazquez Jun 22 '18 at 07:30