I am trying to run my app in Release mode and Link All Assemblies for a smaller app size. However, after adding Unity and some dependency injection I get insta-crash with Link All Assemblies.
Build -> Android Application -> Minimum Android version -> API level 15
Build -> Android Application -> Target Android version -> Api Level 21
Build -> General -> Target framework -> Android 5.0 (Lollipop)
Error:
[monodroid-gc] GREF GC Threshold: 46800
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Microsoft.Practices.Unity.ArrayResolutionStrategy ---> System.InvalidOperationException: Sequence contains no matching element
[MonoDroid] at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
[MonoDroid] at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
[MonoDroid] at Microsoft.Practices.Unity.ArrayResolutionStrategy..cctor () [0x00000] in <filename unknown>:0
[MonoDroid] --- End of inner exception stack trace ---
[MonoDroid] at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
[MonoDroid] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
[MonoDroid] --- End of inner exception stack trace ---
[MonoDroid] at System.Reflection.MonoCMethod.InternalInvoke (object,object[]) <0x00083>
[MonoDroid] at System.Activator.CreateInstance (System.Type,bool) <0x0017b>
[MonoDroid] at System.Activator.CreateInstance (System.Type) <0x00013>
[MonoDroid] at System.Activator.CreateInstance<Microsoft.Practices.Unity.ArrayResolutionStrategy> () <0x00023>
[MonoDroid] at Microsoft.Practices.ObjectBuilder2.StagedStrategyChain`1<Microsoft.Practices.Unity.ObjectBuilder.UnityBuildStage>.AddNew<Microsoft.Practices.Unity.ArrayResolutionStrategy> (Microsoft.Practices.Unity.ObjectBuilder.UnityBuildStage) <0x0001b>
[MonoDroid] at Microsoft.Practices.Unity.UnityDefaultStrategiesExtension.Initialize () <0x00087>
[MonoDroid] at Microsoft.Practices.Unity.UnityContainerExtension.InitializeExtension (Microsoft.Practices.Unity.ExtensionContext) <0x00070>
[MonoDroid] at Microsoft.Practices.Unity.UnityContainer.AddExtension (Microsoft.Practices.Unity.UnityContainerExtension) <0x00083>
[MonoDroid] at Microsoft.Practices.Unity.UnityContainer..ctor () <0x00033>
[MonoDroid] at testapp.Initialize () <0x00023>
[MonoDroid] at testapp.App..ctor () <0x0001b>
[MonoDroid] at testapp.Droid.MainActivity.OnCreate (Android.OS.Bundle) <0x00047>
[MonoDroid] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00048>
[MonoDroid] at (wrapper dynamic-method) object.47e7f7cc-4382-48b0-800b-69e9143892ac (intptr,intptr,intptr) <0x0001f>
[mono]
[mono] Unhandled Exception:
[mono] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Microsoft.Practices.Unity.ArrayResolutionStrategy ---> System.InvalidOperationException: Sequence contains no matching element
[mono] at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
[mono] at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
[mono] at Microsoft.Practices.Unity.ArrayResolutionStrategy..cctor () [0x00000] in <filename unknown>:0
[mono] --- End of inner exception stack trace ---
[mono] at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
[mono] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
[mono] --- End of inner exception stack trace ---
[mono] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
[mono] at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
[mono] at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
[mono] at System.Activator.CreateInstance[ArrayResolutionStrategy] () [0x00000] in <filename unknown>:0
[mono] at Microsoft.Practices.ObjectBuilder2.StagedStrategyChain`1[Microsoft.Practices.Unity.ObjectBuilder.UnityBuildStage].AddNew[ArrayResolutionStrategy] (UnityBuildStage stage) [0x00000] in <filename unknown>:0
[mono] at Microsoft.Practices.Unity.UnityDefaultStrategiesExtension.Initialize () [0x00000] in <filename unknown>:0
[mono] at Microsoft.Practices.Unity.UnityContainerExtension.InitializeExtension (Microsoft.Practices.Unity.ExtensionContext context) [0x00000] in <filename unknown>:0
[mono] at Microsoft.Practices.Unity.UnityContainer.AddExtension (Microsoft.Practices.Unity.UnityContainerExtension extension) [0x00000] in <filename unknown>:0
[mono] at Microsoft.Practices.Unity.UnityContainer..ctor () [0x00000] in <filename unknown>:0
[mono] at testapp.Bootstrapper.Initialize () [0x00000] in <filename unknown>:0
[mono] at testapp.App..ctor () [0x00000] in <filename unknown>:0
[mono] at testapp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
[mono] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
[mono] at (wrapper dynamic-method) object:47e7f7cc-4382-48b0-800b-69e9143892ac (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Microsoft.Practices.Unity.ArrayResolutionStrategy ---> System.InvalidOperationException: Sequence contains no matching element
[mono-rt] at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
[mono-rt] at System.Linq.Enumerable.First[MethodInfo] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
[mono-rt] at Microsoft.Practices.Unity.ArrayResolutionStrategy..cctor () [0x00000] in <filename unknown>:0
[mono-rt] --- End of inner exception stack trace ---
[mono-rt] at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
[mono-rt] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
[mono-rt] --- End of inner exception stack trace ---
[mono-rt] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
[mono-rt] at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
[mono-rt] at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
[mono-rt] at System.Activator.CreateInstance[ArrayResolutionStrategy] () [0x00000] in <filename unknown>:0
[mono-rt] at Microsoft.Practices.ObjectBuilder2.StagedStrategyChain`1[Microsoft.Practices.Unity.ObjectBuilder.UnityBuildStage].AddNew[ArrayResolutionStrategy] (UnityBuildStage stage) [0x00000] in <filename unknown>:0
[mono-rt] at Microsoft.Practices.Unity.UnityDefaultStrategiesExtension.Initialize () [0x00000] in <filename unknown>:0
[mono-rt] at Microsoft.Practices.Unity.UnityContainerExtension.InitializeExtension (Microsoft.Practices.Unity.ExtensionContext context) [0x00000] in <filename unknown>:0
[mono-rt] at Microsoft.Practices.Unity.UnityContainer.AddExtension (Microsoft.Practices.Unity.UnityContainerExtension extension) [0x00000] in <filename unknown>:0
[mono-rt] at Microsoft.Practices.Unity.UnityContainer..ctor () [0x00000] in <filename unknown>:0
[mono-rt] at testapp.Bootstrapper.Initialize () [0x00000] in <filename unknown>:0
[mono-rt] at testapp.App..ctor () [0x00000] in <filename unknown>:0
[mono-rt] at testapp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
[mono-rt] at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
[mono-rt] at (wrapper dynamic-method) object:47e7f7cc-4382-48b0-800b-69e9143892ac (intptr,intptr,intptr)
Im wondering if I should remove Unity as its nice , but not totally needed, or is there a way to get this working and maintain a smaller app size.