gpt4 book ai didi

firebase - 是否可以在没有 google-services.json 配置文件的情况下配置 Firebase 分析?

转载 作者:行者123 更新时间:2023-12-03 15:35:44 26 4
gpt4 key购买 nike

我想为我的一个库模块使用 Firebase 分析。我想以这样一种方式进行编程,即配置文件( google-services.json )应该可以从客户端应用程序文件夹访问或从客户端配置相同。

有没有办法实现上述场景?

提前致谢。

最佳答案

您可以手动初始化库项目配置,如下所示,

欲了解更多信息,请参阅 working-with-multiple-firebase-projects-in-an-android-app

也可以通过how-does-firebase-initialize-on-android了解; Firebase 模块如何自行初始化。

For Android apps using Firebase, there is a central FirebaseApp object that manages the configuration for all the Firebase APIs. This is initialized automatically by a content provider when your app is launched, and you typically never need to interact with it. However, when you want to access multiple projects from a single app, you'll need a distinct FirebaseApp to reference each one individually. It's up to you to initialize the instances other than the default that Firebase creates for you.


FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId("1:530266078999:android:481c4ecf3253701e") // Required for Analytics.
.setApiKey("AIzaSyBRxOyIj5dJkKgAVPXRLYFkdZwh2Xxq51k") // Required for Auth.
.setDatabaseUrl("https://project-1765055333176374514.firebaseio.com/") // Required for RTDB.
.build();
FirebaseApp.initializeApp(this /* Context */, options, "secondary");

希望我已经回答了你的问题。

关于firebase - 是否可以在没有 google-services.json 配置文件的情况下配置 Firebase 分析?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41606331/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com