当我尝试从Firebase Cloud Messages收到通知后打开应用程序时,该应用程序关闭并显示以下错误:
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)
从后台Worker发送的Firebase消息(使用AndroidX.Work) 这并非总是会发生,但是我找不到模式。 我不在Autofac中注册Realm的实例,并且其他已注册的类在构造函数中不包含实例化Realm实例。
此错误是什么意思,我在做什么错?
环境:
答案 0 :(得分:0)
我通过在创建作业和工作程序之前在MainActivity中添加数据库初始化来解决该错误。