0

I am trying to create a simple Android application. I have the latest version of Android Studio and i think both my gradle build files are correct.

I have placed

implementation 'com.google.android.gms:play-services-maps:11.2.0'

in app gradle dependencies.

Due to this I get the following error:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-maps:11.2.0.

I have looked at various links and tried out proposed solutions but none have worked for me.

Below are both my gradle build files.

project 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.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:3.0.0'


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

allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://repo.situm.es/artifactory/libs-release-local" }
}
}

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

app build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 26

defaultConfig {
    applicationId "demo.situm.situmapp"
    minSdkVersion 21
    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'
        matchingFallbacks = ['release', 'debug']
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-maps:11.2.0'
//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'

}

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

Hope you can help.

Thanks, Kabir

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Kabir
  • 1
  • 5

1 Answers1

0

try this i found:

Failed to resolve com.google.android.gms play-services-auth:11.2.0

Add maven to your root level build.gradle file

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

This maven repo is required starting from 11.2.0.

Or add google() repository to your "build.gradle" file. This gradle method is equivalent to

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

repositories {
    jcenter()
    google()
}
Tara
  • 692
  • 5
  • 23
batsheva
  • 2,175
  • 1
  • 20
  • 32
  • I had tried using the maven repo. It didnt work. Also, I had read somewhere that for the latest gradle builld, google() is enough. – Kabir Dec 07 '17 at 10:20
  • did u tried after sync the gradle to invalidate and restart your project after you add maven? anyway you need to add maven, and in your gradle it dosn't exsist, tell us the error after adding maven – batsheva Dec 07 '17 at 11:27
  • I'm getting the same error as before even after adding maven. – Kabir Dec 07 '17 at 11:52