6

I'm getting these errors when I try and build my project, it looks like it thinks I have 2 of the same library, but I'm not sure why:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.room:room-testing:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-core-utils:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.legacy:legacy-support-v4:1.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.inject:guice:4.1.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-appindexing:16.0.2.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-analytics:16.0.5.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads:17.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-runtime:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.lifecycle:lifecycle-extensions:2.0.0.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.room:room-runtime:2.1.0-alpha02.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve androidx.room:room-testing:2.1.0-alpha02.
Open File
Show Details

This is my build.gradle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
    applicationId "com.andydaykin.timer"
    minSdkVersion 24
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
    dexOptions {
        // release & debug is in project animators
        matchingFallbacks = ['release', 'debug']
    }
    debug {
        debuggable true
    }
}
compileOptions {
    targetCompatibility 1.10
    sourceCompatibility 1.10
}
}

allprojects {
repositories {
    google()
    jcenter()
    maven { url 'https://maven.google.com' }
}
}

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

implementation ('androidx.legacy:legacy-support-core-utils:1.0.0') {
    force = true
}
implementation 'androidx.appcompat:appcompat:1.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'com.google.guava:guava:24.1-jre'
implementation 'com.google.inject:guice:4.1'
implementation 'com.google.firebase:firebase-appindexing:16.0.2'
implementation 'com.google.android.gms:play-services-analytics:16.0.5'
implementation 'com.google.android.gms:play-services-ads:17.0.0'

implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0"

def room_version = "2.1.0-alpha02"

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"

testImplementation "androidx.room:room-testing:$room_version"
}

This is my top level gradle build file:

{

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
}
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

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

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
}

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

}

I think this error happened after an upgrade to android studio but I can't remember for sure. My android studio version now is 3.2.1. I was able to get this project to build previously.

Andy
  • 2,138
  • 3
  • 14
  • 14
  • 1
    maybe your gradle has been set to offline? – the newbie coder Nov 23 '18 at 03:50
  • try adding `maven { url "https://maven.google.com" }` repository – Vladyslav Matviienko Nov 23 '18 at 06:35
  • I am also facing same problem let me know if you find any solution i will also do the same. – CodingRat Nov 24 '18 at 13:36
  • Gradle has not been set to offline, and I do have the maven { url "https://maven.google.com" } in the code above. – Andy Nov 25 '18 at 04:32
  • Are you able to make your `play-services-analytics` and `play-services-ads` use the same version number? Additionally, can you post your project-level `build.gradle`? – Jake Lee Nov 28 '18 at 20:05
  • You should not need the allprojects{} section in your lower level build.gradle file. That's for the top level, which you already have. – JoeHz Nov 29 '18 at 00:58
  • @Andy : just to make sure your connection is not behind a firewall or proxy that might be blocking those services. – karan Nov 30 '18 at 04:54
  • @Andy Just try invalidate and restart android studio. I got same problem when I update my android studio for androidx. May works for you – Shweta Chauhan Nov 30 '18 at 07:10
  • 1
    Yeah I've tried to invalidate and restart, unfortunately that didn't work – Andy Nov 30 '18 at 20:33
  • With @thenewbiecoder say that help also connect with internet – Krishna Murari Dec 05 '18 at 14:13
  • Have you checked your language compatibility with your dependencies? try with lower java version once. – Jeel Vankhede Dec 05 '18 at 17:26
  • I've just resolved a very similar issue, so am wondering if you have a similar problem. My project had a few modules and with the change to AndroidStudio (Canary) and needed Gradle upgrade, I started getting a lot of odd symbol resolution errors. They were caused by the change in how symbol dependencies are made visible as compile/implementation/api directives have changed. I resolved mine by making sure the base application included compile time dependencies that previously could be seen in other modules/libraries. It wasn't easy to track them all down, which made this tricky to solve. – Brendon Whateley Dec 05 '18 at 20:58

5 Answers5

2

In your top level Gradle file add class path for google service plugin.

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.0.1'
}

you should check for your internet connection, proxy or firewall.

OR

cross check to disable Gradle Offline by following.

Windows:

Settings >Gradle >Disable Offline Work

Mac:

Preferences > Build, Execution, Deployment >Gradle >Disable Offline Work

enter image description here

Muzammil Husnain
  • 1,218
  • 1
  • 10
  • 24
  • 2
    I already had offline work disabled, the error is still happening with the change to dependencies. – Andy Dec 04 '18 at 05:53
0

Also, check here: https://stackoverflow.com/a/53716633/8034839 and React Native : Could not find com.android.tools.build:gradle:2.2.3 which might help
It is related to AndroidX migration.

Try below solution from https://developer.android.com/jetpack/androidx/migrate

Migrate an existing project using Android Studio

With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

If you have any Maven dependencies that have not been migrated to the AndroidX namespace, the Android Studio build system also migrates those dependencies for you when you set the following two flags to true in your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

To migrate an existing project that does not use any third-party libraries with dependencies that need converting, you can set the android.useAndroidX flag to true and the android.enableJetifier flag to false.

Also, inside your TOP-LEVEL build.gradle, pull up the google() to top as below:

allprojects {
    repositories {
        google() // here
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        //google()
    }
}
shizhen
  • 12,251
  • 9
  • 52
  • 88
  • 1
    Thanks, I already have those 2 properties set. I'm still getting the same error with the change to the top level build.gradle – Andy Dec 04 '18 at 05:52
0

I think this error happened after an upgrade to android studio

The problem just began when you changed compile into implementation.


Assume A,B and C are three modules and the relation between them are as follows

C > B > A    > Represents a dependency


When using compile, C can directly access A. But it is not possible when using implementation. There is api which will have the same effect as compile.


Note: It is not recommended to use api everywhere. api and compile will make the compilation process slower because it will force to recompile all low level modules where implementation will recompile only required modules when a top level module is modified.
Bertram Gilfoyle
  • 9,899
  • 6
  • 42
  • 67
0

If you are using Android Studio 3+ and Gradle version 4.+ then maven is not needed. Try removing

        maven {
            url 'https://maven.google.com/'
            name 'Google'
             }

and just have,

    buildscript {
    repositories {
        google()
        jcenter()

}
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

        // 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
}
Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
-1

Move google() above all other things as below:

    buildscript {
    repositories {
google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }

}
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

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

allprojects {
    repositories {
 google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Vikash Bijarniya
  • 404
  • 4
  • 10