无法更新Firebase依赖项(com.google.firebase)

Nit*_*nde 8 android android-studio firebase-cloud-messaging

我已经为Android应用添加了Firebase以进行推送通知.我在使用之前更新了build.gradle.它的工作正常.

 compile 'com.google.firebase:firebase-messaging:9.2.0'
Run Code Online (Sandbox Code Playgroud)

现在我已更新到最新的库但收到错误.

 dependencies {
  //....
     compile 'com.google.firebase:firebase-core:10.0.1'       
  }
Run Code Online (Sandbox Code Playgroud)

我在Rebuild项目时遇到错误

错误:配置项目':app'时出现问题.无法解析配置':app:_debugApkCopy'的所有依赖项.找不到com.google.firebase:firebase-core:10.0.1.要求:DGApp:app:未指定

先感谢您.

Ab_*_*Ab_ 20

您必须从独立SDK Manager更新Google Play服务和Google Repository.

编辑:从Android Studio的最新版本开始,删除了独立SDK管理器.您必须转到SDK工具选项卡.

首先,打开Android Studio并单击顶部工具栏上的此图标:

图片

然后,在对话框启动时,单击对话框左下角的"Launch Standalone SDK Manager":

图片

要确保更新/安装除我们想要的内容以外的其他内容,请单击"取消全选":

图片

当Standalone SDK Manager窗口打开时,查找"Extras"并将其折叠.您应该会看到"Google Play服务"和"Google存储库",右侧会看到"可用更新:{something}".选择这些项目,然后单击"安装".

图片

安装完成后,错误就会消失.


sas*_*mar 4

添加谷歌服务插件

在 build.gradle 文件中,包含 google-services 插件:

buildscript {
// ...
dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.0.0'
}
}
Run Code Online (Sandbox Code Playgroud)

然后,在模块 Gradle 文件(通常是 app/build.gradle)中,在文件底部添加 apply plugin 行以启用 Gradle 插件:

apply plugin: 'com.android.application'

android {
// ...
 }

dependencies {
 // ...
compile 'com.google.firebase:firebase-core:10.0.1'

// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
 }

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

更多详细信息请参阅 Firebase 设置