I have a native Xamarin.Android app I've built a few years back and I've been maintaining it since then. Lately, I tried to build a new release but the app keeps crashing. I did tens of releases in the past using the same project and compilation settings. Here's an exemple of a stack trace I get in release:
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. [mono-rt] at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction10-21 13:24:49.970 F/mono-rt (15785): File name: 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' [mono-rt] at Java.Interop.JniEnvironmentInfo..ctor () [0x00006] in :0 [mono-rt] at Java.Interop.JniEnvironment+c.b__35_0 () [0x00000] in :0 [mono-rt] at System.Threading.ThreadLocal`1[T].GetValueSlow () [0x00031] in :0 [mono-rt] at System.Threading.ThreadLocal`1[T].get_Value () [0x0003e] in :0 [mono-rt] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in :0ds.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0002d] in :0 [mono-rt] at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in :0 [mono-rt] at Java.Interop.JniEnvironment+StaticMet10-21 13:24:49.970 F/mono-rt (15785): at Android.OS.Looper.get_MainLooper () [0x0000a] in :0 [mono-rt] at Android.Runtime.AndroidEnvironment.GetDefaultSyncContext () [0x00000] in :0 [mono-rt] at System.AndroidPlatform.GetDefaultSyncContext () [0x00000] in :0 [mono-rt] at System.Threading.SynchronizationContext.GetThreadLocalContext () [0x00005] in :0 [mono-rt] at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.Run (System.Threading.Tasks.Task ignored, System.Boolean canInlineContinuationTask) [0x00003] in :0 [mono-rt] at System.Threading.Tasks.Task.FinishStageThree () [0x0003c] in :0 [mono-rt] at System.Threading.Tasks.Task`1[TResult].TrySetResult (TResult result) [0x0004f] in :0 [mono-rt] at System.Threading.Tasks.TaskFactory`1+c__DisplayClass38_0`1[TResult,TArg1].b__0 (System.IAsyncResult iar) [0x00008] in :0 [mono-rt] at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in 10-21 13:24:49.970 F/mono-rt (15785): at (wrapper managed-to-native) System.Runtime.Remoting.Messaging.AsyncResult.Invoke(System.Runtime.Remoting.Messaging.AsyncResult) [mono-rt] at System.Runtime.Remoting.Messaging.AsyncResult.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in :0 [mono-rt] at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in :0
From the stack trace, I have a feeling it might be a problem with the linker, but I have tried all 3 settings (Don't link, link SDK assemblies only, link all). When changing some code here and there, I have sometimes slightly different stack traces, but nothing really helpful. Here's the compilation settings I'm using:
From time to time, the app will launch successfully without changing anytime special. It will only work once.
What I'm I missing?