I've updated my Xamarin.Android app package MvvmCross
from 5.3.2
to 5.4
and app start crashing on startup. Manually I identified that the reason is the linker - I have link SDK libs only
option enabled. With the None
option it works just fine but makes a twice bigger package.
The type initializer for 'MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
This is a known bug in MvvmCross 5.4 and will be fixed in the next version.
In the meantime, as a work around, you can go to your Setup
class and override GetDefaultLogProviderType
so it returns MvxLogProviderType.None
, like this:
protected override MvxLogProviderType GetDefaultLogProviderType()
=> MvxLogProviderType.None;
EDIT
Since the providers rely on reflection, if you wanna use the Console provider with IMvxLog
, simply include this in your LinkerPleaseInclude.cs
:
using System;
//[...]
public void Include(ConsoleColor color)
{
Console.Write("");
Console.WriteLine("");
color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.ForegroundColor = ConsoleColor.Magenta;
Console.ForegroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Gray;
Console.ForegroundColor = ConsoleColor.DarkGray;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With