Anirudh Bagri
Anirudh Bagri

Reputation: 2447

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-basement:[15.0.0,16.0.0)

I am getting this error: Here is my build.gradle(Module:app)

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.mycompany.myapp"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding.enabled = true
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.firebase:firebase-core:15.0.0'
    compileOnly "org.projectlombok:lombok:1.16.20"
    annotationProcessor 'org.projectlombok:lombok:1.16.20'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.0'
    implementation 'com.google.android.gms:play-services-location:15.0.0'
    implementation 'com.google.android.gms:play-services-places:15.0.0'
    implementation 'com.paytm.pgsdk:pgsdk:1.0.8'
    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'
    compile 'com.crashlytics.sdk.android:crashlytics:2.9.1'
}

apply plugin: 'com.google.gms.google-services'

and Here is my build.gradle(Project: myApp)

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'io.fabric.tools:gradle:1.25.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

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

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

I have checked other solutions, most of them suggest to add

maven { url "https://maven.google.com" }

to build.gradle of project. I have already tried this but I am still getting same error.

I am on android studio 3.0. I have also tried adding google() instead of maven (another suggestion)

Upvotes: 19

Views: 29944

Answers (13)

Geek Astuce
Geek Astuce

Reputation: 1

An update of the repository to the latest version solved the problem for me.

implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'

Upvotes: 0

nando
nando

Reputation: 181

If this problem occurred to you suddenly, it may be that it was corrupted while generating the apk. This rarely happens

Solution: rebuild tasks

you can see it in this image

Upvotes: 0

In my case I just changes my just changes my project level build Gradle and other dependencies to the latest and the Google Maps dependency in app level build gradle to 10.0.0.

Upvotes: -1

Yusuf Adefolahan
Yusuf Adefolahan

Reputation: 342

Open top-level build.gradle file and add google-services:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.google.gms:google-services:4.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

also if you already have it added simply update google-service and gradle to the latest

Upvotes: 0

Muhammad Asyraf
Muhammad Asyraf

Reputation: 1808

My issue was...
I can run the project... but suddenly this error came up.
After few tried "Try Again" Solution but not solving.

Finally after few minutes wasted. I Try Clean Project. And Rebuild. Tadaaaa it work.
i dont know if this will help anybody but it solve my issue. hope it solve yours.

Upvotes: 0

Alireza Noorali
Alireza Noorali

Reputation: 3265

Go to File → Other Settings → Default Settings → Build, Execution, Deployment → Build Tools → Gradle → uncheck Offline work option.

Upvotes: 6

Joshua Stephen
Joshua Stephen

Reputation: 206

Have you tried adding this in your dependencies:

implementation 'com.google.android.gms:play-services-basement:15.0.0'

Upvotes: -2

LIH
LIH

Reputation: 933

Just Build → Clean Project worked for me

Upvotes: -2

I had this problem and I was using a proxy before. I figured out that my proxy is not working any more so i went to settings and changed the proxy config to Automatic but still the same error was being shown.

I finally found that the proxy was also automatically set to gradle as well but when I disabled it, it wasn't removed from my gradle config. so I went to C:Users/User/.gradle/gradle.properties and in that file there was something like this:

## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#enter code here
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Aug 31 18:23:27 IRDT 2019
systemProp.https.proxyPort=8118
systemProp.http.proxyHost=fodev.org
systemProp.https.proxyHost=fodev.org
systemProp.http.proxyPort=8118

so I just edited this file and commented the last 4 lines and it solved my problem.

I am also using a VPN service.

Upvotes: 2

VIISHRUT MAVANII
VIISHRUT MAVANII

Reputation: 12698

OPTION 1:

Follow the below instruction to resolve it.

Project-level build.gradle

use

maven { url "https://www.jitpack.io" }

instead of

maven { url "https://jitpack.io" }

OPTION 2:

Project-level build.gradle

google() repository should be 1st priority

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

OPTION 3:

Follow the below steps to resolve it.

Step1:

Project-level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
        classpath 'com.android.tools.build:gradle:3.4.2'

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

allprojects {
    repositories {
        maven { url "http://dl.bintray.com/populov/maven" }
        maven { url "https://jitpack.io" } // For Ucrop
        maven { url "https://maven.google.com" } // Google's Maven repository - FCM
        maven {
            url 'https://dl.bintray.com/azeesoft/maven'
        }
        google()
        jcenter()
        mavenCentral()
    }
}

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

Step2:

App-level build.gradle

I have update One Signal version.

use

implementation 'com.onesignal:OneSignal:3.11.1'

instead of

implementation 'com.onesignal:OneSignal:3.10.9' 

Upvotes: 8

Vrushabh Suchak
Vrushabh Suchak

Reputation: 329

I was using a VPN for internet connection. I closed VPN and it worked for me.

Upvotes: 4

Hamed Jaliliani
Hamed Jaliliani

Reputation: 2929

Using the VPN solved my problem.

Upvotes: 2

Abdulsalam Opeyemi
Abdulsalam Opeyemi

Reputation: 983

I had the same issue while use OneSignal to handle push notifications in my android application.

The solution is to add the exclude clause to its' dependency:

implementation ('com.onesignal:OneSignal:3.8.3'){
    exclude group: 'com.google.android.gms'
}

in the app folder, then add any other missing dependency manually such as:

implementation 'com.google.android.gms:play-services-appinvite:16.1.0'

The problem is that OneSignal SDK contains Google Play Service dependency that are not of the same version with the latest version of gms and firesbase I used in the app.

So I suggest you figure out a dependency you added that uses google play service in the project and use the exclude clause on it. Though your gradle should build if your system is connected to the internet.

Hope this is helpful.

Upvotes: 6

Related Questions