You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET MAUI Android中Plugin.Firebase调用LogEvent触发NullReferenceException

.NET MAUI中Plugin.Firebase GA4 LogEvent在Android触发NullReferenceException问题

我在.NET MAUI应用中使用Plugin.Firebase向Google Analytics(GA4)发送数据,代码如下:

if (DeviceInfo.Platform == DevicePlatform.iOS || DeviceInfo.Platform == DevicePlatform.Android)
{
    if (AgreeToAnalytics)
    {
        var sut = CrossFirebaseAnalytics.Current;

        sut.LogEvent(gaEvent, parameters);
    }
}

在Android平台调用LogEvent()方法时抛出空引用异常:

Plugin.Firebase.Analytics.FirebaseAnalyticsImplementation.LogEvent(String eventName, IDictionary`2 parameters) System.NullReferenceException: Object reference not set to an instance of an object.

相关日志信息:

10-17 13:12:33.857 10916 10916 F mono-rt : [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object. 10-17 13:12:33.857 10916 10916 F mono-rt :
at Plugin.Firebase.Analytics.FirebaseAnalyticsImplementation.LogEvent(String eventName, IDictionary`2 parameters)

我传入的parameters不为空,eventName是有效字符串,参数集合中的所有键值对也都是非空字符串。该功能此前运行正常,推测问题出在从.NET 6迁移到.NET 7的过程中,目前已向插件作者提交Issue但尚未收到回复。

内容的提问来源于stack exchange,提问作者David Shochet

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 12:45:01