I have created a Android app which runs perfectly fine when I debug it in Visual Studio 2019 on my Android phone. But when I publish it to the Google Store and download it and run it on the same phone it crashes right away.
The stack trace is:
android.runtime.JavaProxyThrowable: at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) <0x7e57beb580 + 0x006f0> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) <0x7e57be9354 + 0x00053> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.ResolveInternal (FreshTinyIoC.FreshTinyIoCContainer+TypeRegistration registration, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) <0x7e57beade0 + 0x006ff> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.Resolve (System.Type resolveType) <0x7e57be85d4 + 0x00083> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshTinyIoC.FreshTinyIoCContainer.Resolve[ResolveType] () <0x7e57be8668 + 0x0003b> in <035575fde1c44c4eaa00de78a4f3093f>:0
at FreshMvvm.FreshTinyIOCBuiltIn.Resolve[ResolveType] () <0x7e57b810c0 + 0x00047> in <d2b205c381d14059b4260d7482e68c02>:0
at FreshMvvm.FreshPageModelResolver.ResolvePageModel[T] (System.Object initData) <0x7e57b80c90 + 0x00057> in <d2b205c381d14059b4260d7482e68c02>:0
at FreshMvvm.FreshPageModelResolver.ResolvePageModel[T] () <0x7e57b80c54 + 0x00033> in <d2b205c381d14059b4260d7482e68c02>:0
at GoTexas.App.InitNavigation () <0x7e57b426f4 + 0x00037> in <dd7679dd949e46e680e37995753481d2>:0
at GoTexas.App..ctor () <0x7e57b42600 + 0x0009f> in <dd7679dd949e46e680e37995753481d2>:0
at GoTexas.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) <0x7e54f0b75c + 0x0010f> in <a02812a7c00f4c1c87e549cce19fa824>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) <0x7e598ad064 + 0x0007b> in <899f47c5cea3409e92f041348b58600b>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.7(intptr,intptr,intptr)
at md5b9bd3a38d4378f5ce9f0aa132dfd154f.MainActivity.n_onCreate (Native Method)
at md5b9bd3a38d4378f5ce9f0aa132dfd154f.MainActivity.onCreate (30)
at android.app.Activity.performCreate (Activity.java:7327)
at android.app.Activity.performCreate (Activity.java:7318)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3094)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3257)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1948)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7050)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:964)
So it has something to do with FreshTinyIoC. I just don't get why this works when running off VS 2019 in debug mode off my phone.
Any ideas would be greatly appreciated.
The issue is quite simple actually you have set linking to SDK & User Assemblies which means it is linking everything, your models and every other class, anything that does not have a reference will be collected and removed for better understanding you can check my blog which has an entire section on how to work with Linking:
https://heartbeat.fritz.ai/reducing-the-app-size-in-xamarin-deep-dive-7ddc9cb12688
As of now, I would suggest you can check Link SDK Assemblies
for now and then you can Link everything as that takes a little time
Goodluck, Feel free to get back in case of queries