【问题标题】:Failed Gradle because of firebase-analytics由于 firebase-analytics 导致 Gradle 失败
【发布时间】:2021-01-18 07:59:56
【问题描述】:

我按照说明将 Android 应用添加到 Firebase 项目,但是当我运行代码时出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not find com.google.firebase:firebase-analytics:.
     Required by:
         project :app

我该如何解决?我只是从官方 Firebase 文档中复制和粘贴,我正在使用 Flutter。

app/build.gradle

apply plugin: 'com.google.gms.google-services'
dependencies {
    implementation 'com.google.firebase:firebase-analytics'
    ...
}

android/build.gradle

dependencies{
  classpath 'com.google.gms:google-services:4.3.4'
  ...
}

【问题讨论】:

    标签: android firebase flutter gradle dart


    【解决方案1】:

    您需要为依赖项指定一个版本号。你可以在release notes找到最新版本。

    implementation 'com.google.firebase:firebase-analytics:17.5.0'
    

    但是由于您使用 Flutter 标记了这个问题,如果您正在构建 Flutter 应用程序,您可能应该按照 documentation 中的说明进行操作。

    要使用此插件,请将 firebase_analytics 添加为 dependency in your pubspec.yaml 文件。您还必须为每个平台项目配置 Firebase 分析:Android 和 iOS(请参阅示例文件夹或 https://codelabs.developers.google.com/codelabs/flutter-firebase/#6 了解分步详细信息)。

    您可以在Firebase documentation for Flutter进一步阅读:

    dependencies:
      firebase_analytics: ^5.0.2
    
    

    【讨论】:

      猜你喜欢
      • 2018-02-25
      • 2020-03-13
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 2019-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多