由于Firebase分析导致Gradle失败

时间:2020-10-02 16:18:19

标签: android firebase flutter gradle dart

我按照说明向Firebase项目添加Android应用程序,但是当我运行代码时,它给了我以下错误:

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'
  ...
}

1 个答案:

答案 0 :(得分:1)

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

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

但是,由于您使用Flutter标记了此问题,因此,如果您要构建Flutter应用,则可能应该遵循documentation中的说明。

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

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

dependencies:
  firebase_analytics: ^5.0.2