Android Gradle Failed to Resolve

I am getting this error in my gradle file:

Error: Failed to execute: com.google.android.gms: play-services-measurement: 10.2.4

-Install project repository and sync

-Open file

-Show in the dialog Project structure

But I am not using the play-services dimension in my application. On the other hand, if I click on the "Install Repository and sync project" link, nothing happens. Can anyone help me? I've spent days on this problem.

This is my complete gradle file:

apply plugin: 'com.android.application'    

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'
    }
}



android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    compileOptions {
        encoding "UTF-8"
    }


    lintOptions {
        disable 'MissingTranslation'
        abortOnError false
    }

    defaultConfig {
        applicationId "xxx.yyy.zzz"
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 120
        versionName "1.20"
        multiDexEnabled true
        //Enabling multi dex support due to exceeding the 65K methods dex limit imposed by Android: http://stackoverflow.com/questions/29756188/java-finished-with-non-zero-exit-value-2-android-gradle
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def formattedDate = new Date().format('yyyyMMddHHmmss')
                    def newName = output.outputFile.name
                    newName = newName.replace("app-", "MyAppName") 
                    newName = newName.replace("-release", "-release" + formattedDate)
                    //noinspection GroovyAssignabilityCheck
                    output.outputFile = new File(output.outputFile.parent, newName)
                }
            }
        }

    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':simple-crop-image-lib')

    compile 'com.google.firebase:firebase-core:9.6.1'
    compile 'com.google.firebase:firebase-messaging:10.2.4'
    compile 'com.google.android.gms:play-services:10.2.4' //8.3.0'    10.2.4'  9.0.0' 9.6.0'

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:mediarouter-v7:25.3.1'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'

    //For soap:
    compile files('libs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar')

}

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

      

+3


source to share


2 answers


I was able to remove these lines from "app build.gradle":

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

      



And add them to "project build.gradle":

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.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
    }
}

      

+1


source


Update Google repository in Android SDK. Works for me with version 47.

From firebase doc :



dependencies {
    // ...
    compile 'com.google.firebase:firebase-core:10.2.4'
    compile 'com.google.firebase:firebase-messaging:10.2.4'
    // Getting a "Could not find" error? Make sure you have
    // the latest Google Repository in the Android SDK manager
}

      

+8


source







All Articles