找不到 com.google.firebase:firebase-analytics:。

3

我是firebase的新手,正在尝试在下一个项目中实现firebase。 我包含了以下依赖项,但它显示了上述错误。 如果有人可以提供信息,我将不胜感激。

我的builder.gradle(app)文件如下:

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'

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

    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
apply plugin: 'com.google.gms.google-services'
3个回答

4
当您将Firebase集成到您的应用程序中时,必须根据文档选择两种添加依赖项的方式之一。您可以选择像这样使用每个依赖项的特定版本:
    implementation 'com.google.firebase:firebase-analytics:18.0.0'
    implementation 'com.google.firebase:firebase-firestore:22.0.0'

或者,您可以使用Firebase BoM为您选择它们,基于一个适用于您的特定兼容版本的单个BoM版本:

    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:26.1.0')

    // versions for Firebase SDKs are chosen automatically by the BoM
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-firestore'

看起来你尝试使用了 BoM,但没有添加选择平台的行。


0

当我实现一些Compose UI测试时,我遇到了相同的错误。对我来说,问题在于androidTestImplementation配置实际上没有firebase依赖项。

通过添加以下内容解决:

androidTestImplementation("com.google.firebase:firebase-messaging-ktx")

build.gradle与先前存在的内容一起返回

implementation("com.google.firebase:firebase-messaging-ktx")

根据这篇文章,这实际上没有意义。不过对我来说起作用了。


0

你需要像为其他依赖项指定版本号一样明确地指定版本号。例如:

implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.firebase:firebase-firestore:22.0.0'

在这里,您可以找到有关Firebase版本的更多信息--> https://firebase.google.com/support/release-notes/android


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