When I set linker to link all assemblies, I get this error on Android and on iOS too:
08-25 07:46:23.445: E/AndroidRuntime(9463): FATAL EXCEPTION: main
08-25 07:46:23.445: E/AndroidRuntime(9463): Process: hu.mycompany.myapp, PID: 9463
08-25 07:46:23.445: E/AndroidRuntime(9463): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
08-25 07:46:23.445: E/AndroidRuntime(9463): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
08-25 07:46:23.445: E/AndroidRuntime(9463): Caused by: java.lang.reflect.InvocationTargetException
08-25 07:46:23.445: E/AndroidRuntime(9463): at java.lang.reflect.Method.invoke(Native Method)
08-25 07:46:23.445: E/AndroidRuntime(9463): at java.lang.reflect.Method.invoke(Method.java:372)
08-25 07:46:23.445: E/AndroidRuntime(9463): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
08-25 07:46:23.445: E/AndroidRuntime(9463): ... 1 more
08-25 07:46:23.445: E/AndroidRuntime(9463): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.MissingMethodException: No constructor found for TaxiClientLib.AutoGeneratedITaxiClientRest::.ctor(System.Net.Http.HttpClient, Refit.RequestBuilderImplementation)
08-25 07:46:23.445: E/AndroidRuntime(9463): at System.Activator.CreateInstance (System.Type,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[]) <0x002e3>
08-25 07:46:23.445: E/AndroidRuntime(9463): at System.Activator.CreateInstance (System.Type,object[],object[]) <0x0003b>
08-25 07:46:23.445: E/AndroidRuntime(9463): at System.Activator.CreateInstance (System.Type,object[]) <0x00023>
08-25 07:46:23.445: E/AndroidRuntime(9463): at Refit.RestService.For
08-25 07:46:23.445: E/AndroidRuntime(9463): at Refit.RestService.For
No constructor found for TaxiClientLib.AutoGeneratedITaxiClientRest::.ctor(System.Net.Http.HttpClient, Refit.RequestBuilderImplementation) (System.MissingMethodException)
at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in
at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in
at Refit.RestService.ForITaxiClientRest [0x00000] in
at Refit.RestService.ForITaxiClientRest [0x00000] in
im having the same issue when i deploy my app in release mode, did you find a way to fix it? @westito
Simply linking only SDK. But the binary will be a bit bigger. I can't find another workaround.
+1 Still looking for a way to fix this, linker does not preserve the generated code because it thinks it's unused.
Hi @paulcbetts
Thanks for your hard working for this library. I'm really interesting. But I can't use this library with linker.
Are you planing to make it work with linker in the future?
Please tell me your answer so that I can make my own decision.
Thanks!
Updated:
I added "Refit;" to Ignore assemblies in android project options and it worked like a charm

@paulcbetts there are ways to make libraries Linker safe. (https://developer.xamarin.com/guides/ios/advanced_topics/linker/#Preserving_Code)
Hey Guys
I'm having the same issue in release mode, @paulcbetts are we doing something for workaround ?
Thanks
Riyaz
After a long search, I found the reason for this mis-behaviour when linking option "SDK and User Assemblies" is used.
We have to specify Refit and RefitInternalGenerated explicitly in the list of "Skip linking assemblies".
Note, that list of included assemblies is one line string delimited with semicolon (;) but spaces are not permitted.
I had RefitInternalGenerated as last one, but it wasn't working until I added one additional semicolon at the end of the line.
Here is the sample of "Skip linking assemblies":
Orderion.App;Mono.Data.Sqlite;SQLite-net;SQLitePCLRaw.batteries_green;SQLitePCLRaw.batteries_v2;SQLitePCLRaw.core;SQLitePCLRaw.lib.sqlcipher;SQLitePCLRaw.provider.sqlcipher;MvvmCross.Binding;MvvmCross.Binding.Droid;MvvmCross.Core;MvvmCross.Droid;MvvmCross.Droid.Shared;MvvmCross.Droid.Support.Core.UI;MvvmCross.Droid.Support.Core.Utils;MvvmCross.Droid.Support.Fragment;MvvmCross.Droid.Support.V7.AppCompat;MvvmCross.Droid.Support.V7.RecyclerView;MvvmCross.FieldBinding;MvvmCross.Localization;MvvmCross.Platform;MvvmCross.Platform.Droid;MvvmCross.Plugins.Color;MvvmCross.Plugins.Color.Droid;MvvmCross.Plugins.DownloadCache;MvvmCross.Plugins.DownloadCache.Droid;MvvmCross.Plugins.FieldBinding;MvvmCross.Plugins.File;MvvmCross.Plugins.File.Droid;MvvmCross.Plugins.Json;MvvmCross.Plugins.JsonLocalization;MvvmCross.Plugins.Location;MvvmCross.Plugins.Location.Droid;MvvmCross.Plugins.Messenger;MvvmCross.Plugins.ResourceLoader;MvvmCross.Plugins.ResourceLoader.Droid;MvvmCross.Plugins.Visibility;MvvmCross.Plugins.Visibility.Droid;Simple.OData.Client.Core;Simple.OData.Client.Dynamic;Simple.OData.Client.V4.Adapter;CommonServiceLocator;RefitInternalGenerated;Refit;Microsoft.Azure.Search;
In iOS, you place these in the mtouch arguments box.
--linkskip=AssemblyOne --linkskip=AssemblyTwo
But on Xamarin.Forms better put all your Api interfaces inside one file with a specific namespace and put above it a preserve attribute:
using Xamarin.Forms.Internals;
[assembly: Preserve]
namespace AppoMobi.Models.Api
{
public interface IApi
{
}
...
Closing due to age. Please try Refit v6 and reopen if still an issue.