无法解析:`com.google.android.gms:play-services-appindexing:10.0.0`

32

在设置 compile 'com.google.android.gms:play-services-appindexing:10.0.0' 时,出现以下错误:

Error:(82, 13) Failed to resolve: com.google.android.gms:play-services-appindexing:10.0.0

在设置 compile 'com.google.android.gms:play-services-appindexing:9.8.0' 时,出现以下错误:

Error:Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.0.0.

如果有人能告诉我这个有什么问题,那就太感激了,因为其余的Play服务版本10.0.0都能正常工作。

我的build.gradle文件

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.0'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    signingConfigs {

    }
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 41
        versionName "2.2.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
            signingConfig signingConfigs.config
        }
    }
    lintOptions {
        checkReleaseBuilds false
    }
}

configurations {
    compile.exclude group: 'stax'
    compile.exclude group: 'xpp3'
}

repositories {
    maven {
        url "http://dl.bintray.com/microsoftazuremobile/SDK"
    }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    //Microsoft azure
    compile 'com.microsoft.azure:azure-notifications-handler:1.0.1@aar'
    compile files('libs/notification-hubs-0.4.jar')

    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:support-v4:25.0.1'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.android.support:palette-v7:25.0.1'

    compile 'com.google.android.gms:play-services-auth:10.0.0'
    compile 'com.google.android.gms:play-services-maps:10.0.0'
    compile 'com.google.android.gms:play-services-analytics:10.0.0'
    compile 'com.google.android.gms:play-services-gcm:10.0.0'
    compile 'com.google.android.gms:play-services-appindexing:10.0.0'
    compile 'com.google.android.gms:play-services-base:10.0.0'

    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.android.support:multidex:1.0.1'

    //Facebook SDK
    compile 'com.facebook.android:facebook-android-sdk:4.17.0'

}

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

这很奇怪... :thinking: 你更新了你的SDK吗? - ישו אוהב אותך
你能把你的 build.gradle 文件发布在问题中吗?这会有助于理解你的问题。 - Nitin Karande
请检查您的gradle级别中是否已添加 **classpath 'com.google.gms:google-services:3.0.0'**。 - Nitin Karande
1
@NitinKarande 是的,我已经添加了。 - Krishna Meena
4个回答

39

你所寻找的应用索引库现在已经被移至新的Gradle目标下。

要将compile 'com.google.firebase:firebase-appindexing:10.0.0'添加到你的应用程序的build.gradle文件中 :)

你可以在这里查看最新的可用库


1
这只适用于使用 Firebase 的操作。我改正了我的错误。 - ישו אוהב אותך
但是如果我们在这里检查 https://developers.google.com/android/guides/setup ,他们已经为com.google.android.gms:play-services-appindexing:10.0.0提供了支持。 - Krishna Meena
感谢您指出这一点。该页面已更新以显示名称更改。先前的API仍可在此新的gradle目标中使用,因此不需要进行任何代码更改,除了更改构建目标并将Firebase添加到您的项目中。 - Zayna Shahzad
我认为最好的做法是在所选答案中添加更新后的Play服务链接的注释,而不是提出自己的独立答案,因为对于一些新手来说,这仍然看起来很粗糙。 - Akah

27

现在Google Play服务版本已经发布了10.0.1,因此请将以下内容替换:

compile 'com.google.android.gms:play-services-appindexing:10.0.0'

替换为

compile 'com.google.firebase:firebase-appindexing:10.0.1'


12

你好,当你遇到这种错误时,通常要做的第一件事情是检查你的Android Studio中是否安装了最新版本的Google仓库。我之前也遇到过同样的问题,更新后一切正常了。希望能对你有所帮助。


我就遇到了同样的问题 :) - ZimaXXX
我刚刚检查过了,它已经更新了,但仍然存在同样的问题。 - Dani

5
我需要做两件事情。 添加:
compile 'com.google.firebase:firebase-appindexing:10.0.0'

这似乎是新的。这个API现在被列为唯一的Firebase API,用于所有Google Play服务设置中的APIs here。此外,删除play-services-appindexing编译,因为这个API会取代它:

//no longer include 'play-services-appindexing' compile
//compile 'com.google.android.gms:play-services-appindexing:10.0.0

几个月前,我根据文档的指示在安装Firebase服务时删除了play-services-ads编译,尽管包含它不像现在包括play-services-appindexing那样导致项目编译崩溃。

上传发布APK后,我发现在升级SDK并添加firebase-appindexing编译后,不幸地增加了三个需要的权限。这些权限没有在我的清单中:

android.permission.READ_EXTERNAL_STORAGE,
android.permission.READ_PHONE_STATE, and
android.permission.WRITE_EXTERNAL_STORAGE

编辑于 2016年12月9日: 如Gaurav所评论的,play-services版本10.0.1已经消除了添加的'危险'权限,包括READ_PHONE_STATE,READ_EXTERNAL_STORAGE和WRITE_EXTERNAL_STORAGE,这是我预期在版本10.0.0中进行了清单合并后的结果。这些权限会调用一个特殊的对话框,可能会阻止用户继续使用你的应用程序(“这个游戏试图接管我的手机吗?”)。如果您使用firebase编译,请确保将它们全部升级到10.0.1。它们不会像play-services编译一样变灰,这是应用gradle升级警告中令人遗憾的不一致之处。如果您忽略将firebase编译与play-services编译匹配,您将遇到臭名昭著的“在使用play-services后无法访问zzanb”的项目编译崩溃 - Firebase Error cannot access zzanb after using play-services-xxx:9.8.00


1
你是对的,现在它是 `firebase-appindexing',我也不得不改变实现代码。请参考:https://github.com/googlecodelabs/app-indexing - Ujjwal Singh
1
我不得不改变实现代码。 显然,现在必须指定索引对象和操作对象。 非常令人困惑。特别是因为索引对象只需要添加一次(我应该跟踪已添加的可索引对象吗?),而每当用户执行某些操作时都需要操作对象。 由于某种原因,我再也无法在Google搜索工具栏中获得任何结果了。 - Gillis Haasnoot
1
我猜想在10.0.1版本中,新增权限的问题已经解决了。请分享你的使用体验。 - Gaurav Vashisth

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