【问题标题】:Unable to update the Firebase dependency(com.google.firebase)无法更新 Firebase 依赖项(com.google.firebase)
【发布时间】:2017-04-12 23:54:29
【问题描述】:

我已将 Firebase 添加到 android 应用以进行推送通知。在我使用之前,我已经更新了 build.gradle。它工作正常。

 compile 'com.google.firebase:firebase-messaging:9.2.0'

现在我已更新到最新的库,但出现错误。

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

我在重建项目时遇到了错误

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

提前谢谢你。

【问题讨论】:

  • 在这里查看我的答案。stackoverflow.com/questions/37360126/…这可能会有所帮助
  • 你最近更新了你的支持库吗?检查这个答案stackoverflow.com/a/39302669/3111083
  • 谢谢。现在我正在更新我的 SDK 到最新版本。
  • 请检查我更新的问题。
  • 请看我的回答:)。哦,为这个好问题+1,我实际上遇到了这个问题,我自己解决了,因此我添加了一个答案:)

标签: android android-studio firebase-cloud-messaging


【解决方案1】:

添加 google-services 插件

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

buildscript {
// ...
dependencies {
    // ...
    classpath 'com.google.gms:google-services:3.0.0'
}
}

然后,在您的模块 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'

More details refer Firebase setup

【讨论】:

    【解决方案2】:

    可能是你没有提供正确的回购。

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

    【讨论】:

      【解决方案3】:

      您必须从独立 SDK 管理器更新您的 Google Play 服务和 Google 存储库。

      编辑:在最新版本的 Android Studio 中,独立 SDK 管理器已被移除。您必须转到 SDK 工具选项卡。

      首先,打开 Android Studio 并点击顶部工具栏上的这个图标:

      然后,当对话框启动时,点击对话框左下方的“Launch Standalone SDK Manager”:

      要确保更新/安装我们想要的内容,请单击“取消全选”:

      当独立 SDK 管理器窗口打开时,查找“Extras”并将其折叠。您应该会看到“Google Play Services”和“Google Repository”,并且在右侧您应该看到“可用更新:{something}”。选择这些项目并点击“安装”。

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

      【讨论】:

      • @NitinKarande 有用吗?如果没有,请确保您更新的是“Google Play Services”和“Google Repository”,而不是其他一些 SDK
      【解决方案4】:

      如果您阅读文档,则表明您更新了最新的Google Repository in the Android SDK manager

      那就去Android SDK Managerinstall the latest version of below two libraries

      1-Google Play 服务

      2-Google 存储库

      查看文档中的图片:

      【讨论】:

        【解决方案5】:

        收到“找不到”错误?确保您在 Android SDK 管理器中拥有最新的 Google 存储库。

        解决问题;

        • 打开 SDK 管理器并更新 SDK 工具以获取最新的 SDK 工具,尤其是 Android 7.0(API 24) 下的 Google API

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2014-04-21
          • 2017-07-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多