Xamarin 表单链接器和 Prism.Dryioc
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): UNHANDLED EXCEPTION: 01-03 17:14:04.552 I/MonoDroid(28121): System.TypeInitializationException: The type initializer for 'Registry' threw an exception. ---> System.TypeInitializationException: The type initializer for 'DryIoc.WrappersSupport' threw an exception. ---> DryIoc.ContainerException: Argument of type MethodInfo is null. 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 :0 01-03 17:14:04.552 I/MonoDroid(28121): at DryIoc.WrappersSupport..cctor () [0x0013e] in :0 01-03 17:14:04.552 I/MonoDroid(28121): --- End of inner exception stack trace --- 01-03 17:14:04.552 I/MonoDroid(28121): --- End of inner exception stack trace --- 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].Initialize () [0x0001e] in :0
01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T].InitializeInternal () [0x00006] in :0 01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T]..ctor (Prism.IPlatformInitializer1[T] initializer) [0x00031] in :0 01-03 17:14:04.552 I/MonoDroid(28121): at Prism.DryIoc.PrismApplication.set_ModuleCatalog (Prism.Modularity.IModuleCatalog value) [0x00000] in <5381f1aa51c04a43a2c056545e4b1214>:0 01-03 17:14:04.552 I/MonoDroid(28121): at 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.IntPtr native_savedInstanceState) [0x0000f] in <0c9457d7bcf04178944f1369257ca37d>:0 01-03 17:14:04.552 I/MonoDroid(28121): at (wrapper dynamic-method) System.Object:8b2e8b21-fb7e-4a04-a143-a1dc11f69d85 (intptr,intptr,intptr) 01-03 17:14:04.577 W/art (28121): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable An unhandled exception occured.
谁能帮我找到让 Linker 工作的方法?
我的链接器文件非常错误。我几个小时后修好了。
?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>
所以,当我们使用 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): UNHANDLED EXCEPTION: 01-03 17:14:04.552 I/MonoDroid(28121): System.TypeInitializationException: The type initializer for 'Registry' threw an exception. ---> System.TypeInitializationException: The type initializer for 'DryIoc.WrappersSupport' threw an exception. ---> DryIoc.ContainerException: Argument of type MethodInfo is null. 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 :0 01-03 17:14:04.552 I/MonoDroid(28121): at DryIoc.WrappersSupport..cctor () [0x0013e] in :0 01-03 17:14:04.552 I/MonoDroid(28121): --- End of inner exception stack trace --- 01-03 17:14:04.552 I/MonoDroid(28121): --- End of inner exception stack trace --- 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].Initialize () [0x0001e] in :0
01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T].InitializeInternal () [0x00006] in :0 01-03 17:14:04.552 I/MonoDroid(28121): at Prism.PrismApplicationBase1[T]..ctor (Prism.IPlatformInitializer1[T] initializer) [0x00031] in :0 01-03 17:14:04.552 I/MonoDroid(28121): at Prism.DryIoc.PrismApplication.set_ModuleCatalog (Prism.Modularity.IModuleCatalog value) [0x00000] in <5381f1aa51c04a43a2c056545e4b1214>:0 01-03 17:14:04.552 I/MonoDroid(28121): at 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.IntPtr native_savedInstanceState) [0x0000f] in <0c9457d7bcf04178944f1369257ca37d>:0 01-03 17:14:04.552 I/MonoDroid(28121): at (wrapper dynamic-method) System.Object:8b2e8b21-fb7e-4a04-a143-a1dc11f69d85 (intptr,intptr,intptr) 01-03 17:14:04.577 W/art (28121): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable An unhandled exception occured.
谁能帮我找到让 Linker 工作的方法?
我的链接器文件非常错误。我几个小时后修好了。
?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>