gpt4 book ai didi

android - 无法使 Firebase 为非 Gradle 构建工作 : Missing google_app_id. Firebase Analytics 已禁用

转载 作者:行者123 更新时间:2023-11-29 18:34:15 34 4
gpt4 key购买 nike

我正在开发的应用程序有一个非常定制的构建过程。无法使用 gradle 来构建我的应用程序。这并不理想,但我无法改变任何事情。不过,我想在我的应用程序中使用 Firebase Analytics。包含模块 firebase-core、firebase-common、firebase-analytics、firebase-analytics-impl、firebase-iid、firebase-iid-interop、firebase-measurement-connector、firebase-measurement-connector-imple、play-services-测量基础和播放服务测量 API。我还将以下字符串添加到我的 strings.xml,以及我在 google-services.json 中为我的 Firebase 项目找到的值:

<string name="google_app_id" translatable="false">xxx</string>
<string name="gcm_defaultSenderId" translatable="false">xxx</string>
<string name="default_web_client_id" translatable="false">xxx</string>
<string name="firebase_database_url" translatable="false">xxx</string>
<string name="google_api_key" translatable="false">xxx</string>
<string name="google_crash_reporting_api_key" translatable="false">xxx</string>
<string name="project_id" translatable="false">xxx</string>

(如 here 所述)并从 AndroidManifest 中删除了 FirebaseInitProvider。在我的应用程序 ApplicationonCreate() 我做的:

FirebaseOptions.Builder builder = new FirebaseOptions.Builder()
.setApplicationId(getString(R.string.google_app_id))
.setApiKey(getString(R.string.google_api_key));
FirebaseApp.initializeApp(this, builder.build(), "[DEFAULT]");

目前没有问题。执行上述代码时,我收到一条调试日志消息:

FirebaseApp: com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.

很好,我没有包含 auth 模块。我的应用程序不需要它。当我调用 FirebaseAnalytics.getInstance(adblockSettingsTextView.getContext()).getFirebaseInstanceId() 时,它返回一个字符串值,因此我假设初始化成功。

现在每次我想记录这样的事件

Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "Dashboard");
FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);

我在日志中看到一个错误,提示 Missing google_app_id。 Firebase 分析已禁用。请参阅 https://firebase.google.com/docs/android/setup。 最重要的是,我在 Firebase Analytics 仪表板中看不到任何活跃用户。

我阅读了所有我能找到的文档,并尽我所能找出这个问题的原因。但是现在我不知道我可以检查或更改什么以使其工作。帮助将不胜感激。谢谢!

最佳答案

如果其他人遇到同样的问题,我将从 Firebase 支持那里得到的答案留在此处:

Google Analytics for Firebase (GA4F) doesn't support dynamic initialization. Our engineers are checking the possible solutions to support this. It's just that we still haven't found a definite timeline as to when (or if) this will be available.

GA4F will not work without the google-services.json file (or Gradle on your end). Even though you can initialize the FirebaseApp dynamically through code, GA4F will not recognize this and will only result in the error message you are seeing. The scenario you are getting is only specific to Google Analytics for Firebase. However, you can still use other products like Firestore, Realtime Database, Storage even if you are not using Gradle plugin.

关于android - 无法使 Firebase 为非 Gradle 构建工作 : Missing google_app_id. Firebase Analytics 已禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54927957/

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