Xamarin Forms Linker and Prism.Dryioc



所以,当我们使用Xamarin Forms时,我们需要一个小的apk大小。为了实现这一目标,我们有 Linker 和 Proguard。

但是使用Prism.Dryioc我卡住了,我真的不知道如何正确设置我的Link配置文件。

<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="Prism.Forms">
<type fullname="Prism.Common.ApplicationProvider" preserve="all" />
<type fullname="Prism.Services.PageDialogService" preserve="all" />
<type fullname="Prism.Services.DeviceService" preserve="all" />
</assembly>
<assembly fullname="Prism.DryIoc.Forms" >
<namespace fullname="Prism.DryIoc" preserve="all" />
</assembly>
<assembly fullname="Prism">
<namespace fullname="Prism.Ioc" preserve="all" />
</assembly>
<assembly fullname="netstandard">
<namespace fullname="System.Reflection" preserve="all" />
<namespace fullname="System.Xml" preserve="all" />
</assembly>
</linker>

有了上面,我得到了这个例外:

01-03 17:14:04.526 I/MonoDroid(28121):未处理的异常:01-03 17:14:04.552 I/MonoDroid(28121):System.TypeInitializationException:"注册表"的类型初始值设定项引发异常。 --->

System.TypeInitializationException:'DryIoc.WrappersSupport' 的类型初始值设定项引发了异常。 ---> DryIoc.ContainerException:MethodInfo 类型的参数为空。 01-03 17:14:04.552 I/MonoDroid(28121): at DryIoc.Throw.ThrowIfNull[T] (T arg, System.Int32 error,System.Object arg0, System.Object arg1, System.Object arg2, System.Object arg3) [0x0002b] in :001-03 17:14:04.552 I/MonoDroid(28121):at DryIoc.WrappersSupport..CCTOR () [0x0013e] in :001-03 17:14:04.552 I/MonoDroid(28121): --- 内部异常堆栈跟踪结束 --- 01-03 17:14:04.552 I/MonoDroid(28121): --- 内部异常堆栈跟踪结束 --- 01-03 17:14:04.552 I/MonoDroid(28121): at Prism.DryIoc.PrismApplication.CreateContainer () [0x00006] in <5381f1aa51c04a43a2c056545e4b1214>:0 01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T].在 :0 中初始化 () [0x0001e]

01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T].初始化内部 () [0x00006] 在 :0 中01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T].ctor (Prism.IPlatformInitializer1[T] initializer) [0x00031] in :001-03 17:14:04.552 I/MonoDroid(28121):在Prism.DryIoc.PrismApplication.set_ModuleCatalog(棱镜模块化.IModuleCatalog value)[0x00000]在<5381f1aa51c04a43a2c056545e4b1214>:0 01-03 17:14:04.552 I/MonoDroid(28121):在 Mobile.App。ctor (Prism.DryIoc.IPlatformInitializer initializer) [0x00000] in C:\Projetos\ECS_APP\Mobile\Mobile\App.xaml.cs:33 01-03 17:14:04.552 I/MonoDroid(28121): at Mobile.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x000b2] in C:\Projetos\ECS_APP\Mobile\Mobile.Android\MainActivity.cs:41 01-03 17:14:04.552 I/MonoDroid(28121): at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtrnative_savedInstanceState) [0x0000f] in <0c9457d7bcf04178944f1369257ca37d>:0 01-03 17:14:04.552 I/MonoDroid(28121): at (包装器动态方法) System.Object:8b2e8b21-fb7e-4a04-a143-a1dc11f69d85 (intptr,intptr,intptr) 01-03 17:14:04.577 w/art (28121): JNI RegisterNativeMethods: 尝试为 android.runtime.JavaProxyThrowable 注册 0 个本机方法 发生未处理的异常。

有人可以帮助我找到使链接器工作的方法吗?

我的链接器文件非常错误。几个小时后我修复了。

?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="SQLite-net">
<type fullname="*" />
</assembly>
<assembly fullname="SQLitePCLRaw.batteries_v2">
<type fullname="*" />
</assembly>
<assembly fullname="SQLitePCLRaw.core">
<type fullname="*" />
</assembly>
<assembly fullname="DryIoc">
<type fullname="*" />
</assembly>
<assembly fullname="System">
<type fullname="*" />
</assembly>
<assembly fullname="mscorlib">
<type fullname="*" />
</assembly>
<assembly fullname="Prism">
<type fullname="*" />
</assembly>
<assembly fullname="Prism.DryIoc.Forms">
<type fullname="*" />
</assembly>
<assembly fullname="MyProjectPCL">
<type fullname="*" />
</assembly>
<assembly fullname="Prism.Forms">
<type fullname="*" />
</assembly>
<assembly fullname="Plugin.Permissions">
<type fullname="*" />
</assembly>
<assembly fullname="Xamarin.Forms.Maps">
<type fullname="*" />
</assembly>
<assembly fullname="Newtonsoft.Json">
<type fullname="*" />
</assembly>
</linker>

最新更新