Xamarin Android - Linking User assemblies causes FreshMvvm to not work

Jamie Colclough 1 Reputation point
2021-05-28T10:33:10.467+00:00

Hi,
I have a Xamarin application that is structured as a typical application (PCL Project, Project.Droid, Project.IOS). I use FreshMvvm for navigating between ViewModels and for dependency injection.
I've been trying to use the linker to deploy the android side of my linker, but when I have the linker option as (Sdk and User Assemblies), FreshMvvm doesn't seem to work. For example, when trying to resolve a dependency using FreshIOC.Container.Resolve<ISettingsHelper>().Get(Constants.QRCodeSetting, "");, I get the following error:

FreshTinyIoC.TinyIoCResolutionException
  Message=Resolve failed: SettingsHelper
  Source=FreshIOC
  StackTrace:
  at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x0005f] in <c21cfb4c083e4f8c8ae2f9248f9e60c5>:0 
  at FreshTinyIoC.FreshTinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, FreshTinyIoC.ResolveOptions options) [0x00009] in <c21cfb4c083e4f8c8ae2f9248f9e60c5>:0 
  at FreshTinyIoC.FreshTinyIoCContainer+SingletonFactory.GetObject (System.Type requestedType, FreshTinyIoC.FreshTinyIoCContainer container, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x0003b] in <c21cfb4c083e4f8c8ae2f9248f9e60c5>:0 
  at FreshTinyIoC.FreshTinyIoCContainer.ResolveInternal (FreshTinyIoC.FreshTinyIoCContainer+TypeRegistration registration, FreshTinyIoC.NamedParameterOverloads parameters, FreshTinyIoC.ResolveOptions options) [0x00026] in <c21cfb4c083e4f8c8ae2f9248f9e60c5>:0 
  at FreshTinyIoC.FreshTinyIoCContainer.Resolve (System.Type resolveType) [0x00011] in <c21cfb4c083e4f8c8ae2f9248f9e60c5>:0 
  at FreshTinyIoC.FreshTinyIoCContainer.Resolve[ResolveType] () [0x00000] in <c21cfb4c083e4f8c8ae2f9248f9e60c5>:0 
  at FreshMvvm.FreshTinyIOCBuiltIn.Resolve[ResolveType] () [0x00000] in /Users/michaelridland/Projects/FreshMvvm/src/FreshMvvm/FreshTinyIOCBuiltIn.cs:36 
  at Project.App.PerformInitialNavigation () [0x00001] in D:\Project\Project\App.xaml.cs:79 
  at Project.App..ctor () [0x0005d] in D:\Project\Project\App.xaml.cs:33 
  at Project.Droid.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x00077] in D:\Project\Droid\MainActivity.cs:49 
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00010] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.App.Activity.cs:2691 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.12(intptr,intptr,intptr)

Any ideas why this might be? I've tried adding all of the assemblies to the "Skip linking assemblies" section (apart from the pcl as this causes a build error) but the error still happens.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,342 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.