解析失败:com.google.android.gms:play-services-measurement:9.6.1

新手上路,请多包涵

今天我将我所有的支持库和构建工具更新到最新版本以支持 Android N 。一旦我更新了所有内容并运行了应用程序,我的应用程序中 InstanceId 生成方法 GCM 出现错误。因此,我搜索并找到了建议也更新播放服务的解决方案。看完所有的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 服务也更新了。 在此处输入图像描述

原文由 Amit Tiwari 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 968
2 个回答

最后,我自己解决了。这是我所做的:

  1. 去掉 compile 'com.google.android.gms:play-services-measurement:9.6.1' 然后编译工程
  2. 它给出了 missing api_key error 因为 GCM 被转移到 Firebase 所以 google-services.json 文件不工作
  3. 要解决此问题,只需使用使用来自 Firebase 的云消息传递的新生成文件更新 google-services.json 文件
  4. 在此之后,我编译并得到另一个错误 @drawable/powered_by_google_dark 在我使用 Places Autocomplete API 时从项目中丢失。要解决此问题,请将 compile 'com.google.android.gms:play-services-places:9.6.0' 添加到依赖项

原文由 Amit Tiwari 发布,翻译遵循 CC BY-SA 3.0 许可协议

今天我遇到了同样的问题。这为我解决了问题:

打开独立的 Android SDK 管理器。在 Extras 部分,“Google Play Services”是最新版本,但在将“Google Repository”从版本 33 更新到 35 后,“Google Repository”问题消失了。

原文由 JPLauber 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题