无法解析:com.google.android.gms:play-services-measurement:9.6.1

10
今天我更新了所有的支持库和构建工具到最新版本,以支持Android N。一旦我更新了一切并运行了应用程序,就会在我的应用程序中的GCM中的InstanceId生成方法中遇到错误。因此,我搜索并找到了解决方案,建议也更新play-services。在遵循所有SO问题和答案后,我卡住了,无法前进。 回滚到支持库23.x.x不是一个选项,因为我想针对Android N进行目标设置。
这是我的项目级别build.gradle文件的外观:
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()
    }
}

应用程序级别的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'

这是我遇到的错误: 在此输入图片描述

非常感谢任何帮助。谢谢。

编辑

我的Google Play服务也已更新。 在此输入图片描述

5个回答

5

今天我遇到了同样的问题。以下方法解决了我的问题:

打开独立的Android SDK管理器。在“Extras”部分,如果“Google Play服务”已经是最新版本,则需要更新“Google Repository”从33版本升级到35版本,这样问题就会消失了。


我曾经遇到过类似的问题……在升级 Android/Studio 和 SDK 的过程中,某些东西崩溃了。当我回到 SDK 管理器时,Google Play ServicesGoogle Repository 都没有被安装。重新安装它们后,一切都正常了。 - tir38

3

您的谷歌播放服务版本不是最新的,只需点击链接,Android Studio 将提供安装对话框。


3
我点击了链接,但没有反应。 - Amit Tiwari
你尝试过使用9.6.0而不是9.6.1吗?我认为目前还没有9.6.1的版本。 - JPLauber

3

最终,我自己解决了这个问题。下面是我的解决方法:

  1. 移除compile 'com.google.android.gms:play-services-measurement:9.6.1',然后编译项目
  2. 由于GCM转移到Firebase,所以出现missing api_key error,因此google-services.json文件无法工作
  3. 为了解决这个问题,只需使用新生成的文件更新google-services.json文件,该文件从Firebase使用云消息传递
  4. 之后,我编译时遇到另一个错误,即项目中缺少@drawable/powered_by_google_dark,因为我正在使用Places Autocomplete API。为了修复这个问题,需要将compile 'com.google.android.gms:play-services-places:9.6.0'添加到依赖项中

1
将所有播放服务的依赖项设置为9.6.0。9.6.1尚未发布。如果问题仍然存在,请在您的Android Studio中安装最新的Google Play服务和存储库。

我已将所有依赖项更改为9.6.0,但仍然遇到相同的错误。此外,我的Play服务也已更新。请参见编辑。 - Amit Tiwari
1
尝试将项目级build.gradle中的此行更改为:classpath 'com.google.gms:google-services:2.1.0',原先是classpath 'com.google.gms:google-services:3.0.0'。可以从参考资料中找到这个信息。 - Sudip Podder
仍然是同样的问题。 - Amit Tiwari

1
有时候发生这种情况是因为您没有连接到互联网。 连接到互联网并重新构建您的项目,错误就会消失。 对我来说,这种方法很有效。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接