如果 Build Gradle 界面不同,您可以通过在根目录下的 build.gradle 文件中添加以下代码行来安装 Firebase:
buildscript {
dependencies {
// Add the Firebase SDK for Google Analytics
classpath 'com.google.firebase:firebase-analytics:17.2.1'
}
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
如果您的 Firebase 已成功安装,则可以在您的应用程序级别的 build.gradle 文件中导入 Firebase 工具包,并在您的项目中使用它。请注意,您需要先在 Firebase 控制台中设置您的 Firebase 项目和添加应用,然后才能在应用程序中使用 Firebase。
dependencies {
// Import Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.1'
}
希望这可以解决您的问题!