Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve: com.google.android.gms:play-services-measurement:9.6.1

Today I updated all my support libraries and buildtools to the latest version to support Android N. Once I updated everything and ran the app, I got an error in InstanceId generation method of GCM in my app. So, I searched and found solutions that suggested to update play-services too. After following all the SO questions and answers, I am stuck and can't move forward. Switching back to support libraries 23.x.x is not an option as I want to target Android N.

Here is how my project level build.gradle files look:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

App level build.gradle:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
//        maven { url 'http://hansel.io/maven' }
        maven {
            url "https://jitpack.io"
        }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
//        classpath 'io.hansel.preprocessor:preprocessor:1.0.+'
    }
}


apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
//apply plugin: 'io.hansel.preprocessor'


android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    signingConfigs {

    }
    defaultConfig {
        applicationId 'com.example.android'
        multiDexEnabled true
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 47
        versionName "1.3.2"
        renderscriptTargetApi 24
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        debug {
            applicationIdSuffix = ".dev"
            resValue "string", "app_name", "example-debug"
        }
        release {
            minifyEnabled false
            shrinkResources false
            resValue "string", "app_name", "example"
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 16
        }
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

repositories {
    mavenCentral()
    mavenLocal()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
//    maven { url 'http://hansel.io/maven' }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:support-annotations:24.2.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:24.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.3.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
    compile 'com.android.support:recyclerview-v7:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.github.clans:fab:1.6.1'
    compile 'com.facebook.fresco:fresco:0.8.1+'
    compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1+'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.google.android.gms:play-services-analytics:9.6.1'
    compile 'com.google.android.gms:play-services-location:9.6.1'
    compile 'com.google.android.gms:play-services-gcm:9.6.1'
    compile 'com.google.android.gms:play-services-measurement:9.6.1'
    compile 'com.github.liuguangqiang.swipeback:library:1.0.2@aar'
    compile 'me.imid.swipebacklayout.lib:library:1.0.0'
    compile 'com.github.2359media:EasyAndroidAnimations:0.8'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.0.+'
    compile 'com.wang.avi:library:1.0.1'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.mixpanel.android:mixpanel-android:4.6.4'
    compile 'com.github.ppamorim:dragger:1.2'
    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'io.reactivex:rxjava:1.1.3'
    compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
//    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
//    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
    compile 'com.bignerdranch.android:expandablerecyclerview:2.1.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.birbit:android-priority-jobqueue:2.0.0'
    compile 'com.squareup:otto:1.3.8'
    compile 'com.mikhaellopez:circularprogressbar:1.1.1'
    compile 'com.github.dotloop:aosp-exif:be25ae51ec'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        exclude group: 'com.squareup.okhttp', module: 'okhttp'
        transitive = true;
    }
}
apply plugin: 'com.google.gms.google-services'

And this is the error I am getting: enter image description here

Any help would be highly appreciated. Thanks.

Edit

My google play services is also updated. enter image description here

like image 933
Amit Tiwari Avatar asked Sep 26 '16 07:09

Amit Tiwari


2 Answers

Well sometime it happens when you are not connected to the internet. Connect to internet and rebuild your project and the error will be gone. Worked for me this way.

like image 170
Shivam Singh Avatar answered Sep 20 '22 03:09

Shivam Singh


Finally, I solved it myself. Here is what I did:

  1. Removed compile 'com.google.android.gms:play-services-measurement:9.6.1' and then compiled the project
  2. It gives missing api_key error because GCM got shifted to Firebase and so the google-services.json file does not work
  3. To fix this, simply update the google-services.json file with the new generated file which uses Cloud messaging from Firebase
  4. After this, I compiled and got another error that @drawable/powered_by_google_dark is missing from the project as I am using Places Autocomplete API. To fix this, add compile 'com.google.android.gms:play-services-places:9.6.0' to dependencies
like image 33
Amit Tiwari Avatar answered Sep 20 '22 03:09

Amit Tiwari