[英]Where should I add project level dependencies for firebase in new Android Studio projects
I created an Android project from Android Studio Bumblebee and I am trying to integrate Firebase into it.我从 Android Studio Bumblebee 创建了一个 Android 项目,我正在尝试将 Firebase 集成到其中。 As per the documentation from Firebase, I should add some project level and module level dependencies which are shown below.
根据 Firebase 的文档,我应该添加一些项目级别和模块级别的依赖项,如下所示。
When I go to my project level Gradle file it is something like this:当我 go 到我的项目级别 Gradle 文件时,它是这样的:
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So my question is, where should I add these dependencies?所以我的问题是,我应该在哪里添加这些依赖项?
Solved it by adding build script in the top通过在顶部添加构建脚本来解决它
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and the google()
repositories mentioned can be excluded as its there by default.并且默认情况下可以将提到的
google()
存储库排除在外。
Add the following piece of code添加以下代码
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
Add this inside Root project build.gradle
在根项目
build.gradle
添加这个
plugins {
id 'com.google.gms.google-services' version '4.3.10' apply false
id 'com.google.firebase.crashlytics' version '2.9.1' apply false
.... some others classpath
}
And this inside the App Module build.gradle
这在应用模块
build.gradle
plugins {
.... some others plugins
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
And finally...最后...
implementation platform('com.google.firebase:firebase-bom:30.3.1')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
So force a crash in your code, something like this所以强制你的代码崩溃,像这样
throw RuntimeException("Crashlytics Test")
Now check your Firebase Console现在检查您的Firebase 控制台
Done!完毕!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.