Android “如何修复”;在使用默认架构创建领域实例之前,应调用AddDefaultTypes;
当我在收到Firebase云消息的通知后尝试打开应用程序时,应用程序将关闭,并出现以下错误:Android “如何修复”;在使用默认架构创建领域实例之前,应调用AddDefaultTypes;,android,xamarin,realm,Android,Xamarin,Realm,当我在收到Firebase云消息的通知后尝试打开应用程序时,应用程序将关闭,并出现以下错误: 07-09 12:24:22.404 Samsung SM-A510F Info 15570 MonoDroid System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.No
07-09 12:24:22.404 Samsung SM-A510F Info 15570 MonoDroid System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> System.NotSupportedException: AddDefaultTypes should be called before creating a Realm instance with the default schema. If you see this error, please report it to help@realm.io.
at Realms.Schema.RealmSchema.AddDefaultTypes (System.Collections.Generic.IEnumerable`1[T] types) [0x00029] in <62b40c9633874f2cb89599c718233d7b>:0
at RealmModuleInitializer.Initialize () [0x00000] in <24d2a06b332042f2a7af7631479a79db>:0
at <Module>..cctor () [0x00000] in <24d2a06b332042f2a7af7631479a79db>:0
--- End of inner exception stack trace ---
at Autofac.Module.Configure (Autofac.Core.IComponentRegistry componentRegistry) [0x0001a] in <57e4c9c21cbb498aacce99da9e049074>:0
at Autofac.ContainerBuilder.Build (Autofac.Core.IComponentRegistry componentRegistry, System.Boolean excludeDefaultModules) [0x0004b] in <57e4c9c21cbb498aacce99da9e049074>:0
at Autofac.ContainerBuilder.Build (Autofac.Builder.ContainerBuildOptions options) [0x0002e] in <57e4c9c21cbb498aacce99da9e049074>:0
at Retail360.Kernel.Build () [0x00071] in <3e794d04561a416fae55be827fe69b19>:0
at Retail360.App..ctor () [0x00015] in <3e794d04561a416fae55be827fe69b19>:0
at Retail360.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0003d] in <9722cafe2466481e865733de664af995>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <2530aa2e412d4754af3ae7e1a8c80b6d>:0
at (wrapper dynamic-method) System.Object.12(intptr,intptr,intptr)
07-09 12:24:22.404三星SM-A510F信息15570 MonoDroid System.TypeInitializationException:“”的类型初始值设定项引发异常。-->System.NotSupportedException:AddDefaultTypes应在使用默认架构创建领域实例之前调用。如果您看到此错误,请将其报告给help@realm.io.
位于:0中的Realms.Schema.RealmSchema.AddDefaultTypes(System.Collections.Generic.IEnumerable`1[T]类型)[0x00029]
在0中的RealmModuleInitializer.Initialize()[0x00000]处
0中的..cctor()[0x00000]处
---内部异常堆栈跟踪的结束---
在0中的Autofac.Module.Configure(Autofac.Core.IComponentRegistry componentRegistry)[0x0001a]处
在Autofac.ContainerBuilder.Build(Autofac.Core.IComponentRegistry componentRegistry,System.Boolean excludeddefaultmodules)[0x0004b]中:0
在:0中的Autofac.ContainerBuilder.Build(Autofac.Builder.ContainerBuildOptions选项)[0x0002e]处
位于:0中的Retail360.Kernel.Build()[0x00071]
位于Retail360.App..ctor()[0x00015]的位置:0
在Retail360.Droid.MainActivity.OnCreate(Android.OS.Bundle savedInstanceState)[0x0003d]中:0
在Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(System.IntPtr jnienv,System.IntPtr native_此,System.IntPtr native_savedInstanceState)[0x00011]中:0
at(包装器动态方法)System.Object.12(intptr,intptr,intptr)
从后台工作程序发送Firebase消息(使用AndroidX.Work)
这种情况并不总是发生,但我找不到模式。
我没有在Autofac中注册领域实例,其他注册的类在构造函数中没有包含实例化领域实例
这个错误意味着什么?我做错了什么
环境:
- 手机为三星A5安卓7.0或OnePlus 6T安卓9李>
- Xamarin表格3.6.0.539721
- 领域4.0.1
- Autofac 4.9.2
- Xamarin.Firebase.Messaging 60.1142.1