android - 找不到 com.google.firebase:firebase-analytics:
问题描述
我是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'
解决方案
根据文档,当您将 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,但没有添加用于选择平台的行。
推荐阅读
- javascript - 产品类别的 useParams
- powerbi - 如何使用相同的过滤器分别过滤两个重复的列?
- python - Django Form 无法正确保存
- reactjs - React-如何将反应图标添加到根据 Formik / Yup 验证更改的输入字段?
- android - Gradle 构建卡住了
- python-3.x - 根据元素以不同顺序对列表进行排序
- python - 在 Python 中将多个文件夹(在目录中)压缩到单个文件(在新目录中)
- java - Spring boot application.properties 如何读取日文或片假名字符
- image - 如何在 Sphinx 的图像指令中替换:target:?
- kiwi-tcms - 将测试用例数据从 Kiwi 数据库导出到我们的系统