【问题标题】:Failed to resolve: com.google.android.gms:play-services-measurement:9.6.1无法解决:com.google.android.gms:play-services-measurement:9.6.1
【发布时间】:2016-09-26 07:45:40
【问题描述】:

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

【问题讨论】:

    标签: android android-studio android-gradle-plugin google-play-services


    【解决方案1】:

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

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

    【讨论】:

    • 我遇到了类似的问题...在升级 Android/Studio 和 SDK 的过程中发生了崩溃。当我回到 SDK Manager 时,Google Play ServicesGoogle Repository 都没有安装。在(重新)安装它们之后一切正常。
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      您没有最新的google play服务,只需点击链接,android studio会提供一个对话框来安装它。

      【讨论】:

      • 我点击了链接,没有任何反应。
      • 您是否尝试过使用 9.6.0 而不是 9.6.1。我认为还没有 9.6.1
      【解决方案4】:

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

      【讨论】:

      • 我将所有依赖项更改为 9.6.0,但仍然遇到相同的错误。另外,我的游戏服务也更新了。查看编辑。
      • 尝试在您的项目级别 build.gradle 中将这一行 classpath 'com.google.gms:google-services:3.0.0' 更改为 classpath 'com.google.gms:google-services:2.1.0'。从this 参考资料中找到这个。
      • 还是同样的问题。
      【解决方案5】:

      嗯,有时它会在您未连接到互联网时发生。 连接到互联网并重建您的项目,错误就会消失。 以这种方式为我工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-09
        • 2022-01-14
        • 2019-04-15
        • 2018-11-23
        • 1970-01-01
        • 1970-01-01
        • 2018-01-04
        • 2017-03-06
        相关资源
        最近更新 更多