【问题标题】:Firebase analytics event not show up on firebase consoleFirebase 分析事件未显示在 Firebase 控制台上
【发布时间】:2017-01-11 10:10:45
【问题描述】:

我在我的应用程序中实现了firebase analytics,但没有显示任何事件或登录火基控制台。

onCreateView()方法的每个片段中添加如下代码。

private void addFragmentInFirebaseAnalytics() {

    FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(getContext());
    FragmentItem fragmentItem = new FragmentItem();
    fragmentItem.setFragmentId(Constant.FM_ID_MOIST_AIR);
    fragmentItem.setFragmentName(MoistAirActivity.class.getSimpleName());

    Bundle bundle = new Bundle();
    bundle.putInt(FirebaseAnalytics.Param.ITEM_ID, fragmentItem.getFragmentId());
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, fragmentItem.getFragmentName());

    //Logs an app event.
    firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
    Log.d(TAG,"bundle >>"+bundle);
}

使用的依赖是:

compile 'com.google.firebase:firebase-core:9.4.0'

使用的插件:

apply plugin: 'com.google.gms.google-services'

它工作正常并在调试控制台中显示这样的日志,

    09-14 12:30:42.967 D/FA      ( 8821): Logging event (FE): select_content, Bundle
[{_o=app, _ev=item_id, item_name=MoistAirActivity, content_type=Navigation Menu,
 _err=4}]
09-14 12:30:42.977 V/FA      ( 8821): Using measurement service
09-14 12:30:42.977 V/FA      ( 8821): Connecting to remote service
09-14 12:30:43.217 D/FA      ( 8821): Connected to remote service
09-14 12:30:43.217 V/FA      ( 8821): Processing queued up service tasks: 1
09-14 12:30:43.217 E/FA      ( 8821): Task exception on worker thread: java.lang
.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist. : com.goo
gle.android.gms.measurement.internal.zzt.zzEd(Unknown Source)
09-14 12:30:48.217 V/FA      ( 8821): Inactivity, disconnecting from AppMeasurem
entService

但 24 小时后在调试控制台和 Firebase 控制台中不显示任何上传消息,

那么,这里有什么问题吗?请帮忙。

【问题讨论】:

标签: android firebase-analytics


【解决方案1】:

这里可能会发生一些事情。如果您运行,您将看到更多诊断消息:

adb shell setprop log.tag.FA VERBOSE  

如果您的测试设备安装了 Google Play 服务,请同时运行:

adb shell setprop log.tag.FA-SVC VERBOSE

这些命令将在您的 logcat 中显示更多信息。应用启动时 FA 或 FA-SVC 是否有任何错误?

【讨论】:

  • 现在一切正常并记录了firebase消息,但数据没有上传到firebase控制台并生成异常E / FA:工作线程上的任务异常:java.lang.IllegalStateException:FirebaseApp名称为[DEFAULT ] 不存在。 : com.google.android.gms.measurement.internal.zzt.zzbpu(Unknown Source)
  • 看看这个答案,看看它是否有帮助:stackoverflow.com/questions/37342403/…
  • 您是否尝试过此答案中的想法? stackoverflow.com/questions/37531749/…
【解决方案2】:

最后我通过替换tools:node="replace" to tools:node="merge" 并在清单文件中添加tools:replace="android:label" 解决了这个问题。

参考:FirebaseApp with name [DEFAULT] doesn't exist

【讨论】:

  • 为什么我们需要这个?任何想法? @vishal gandhiya
【解决方案3】:

对我来说这很有效:

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />

在 AndroidManifest.xml 中。

我没有指定任何工具属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-04
    • 2022-07-21
    • 1970-01-01
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多