3

My Xamarin Forms app (for Android) in release mode have size 39 Mb. I enabled option "Link All Assemblies". I read about this option and I understand that this is difficult. But the big way starts with the first step. I have this exception:

10-30 20:25:18.895 I/MonoDroid(12805): UNHANDLED EXCEPTION:
Thread started: <Thread Pool> #9
10-30 20:25:19.023 I/MonoDroid(12805): System.NullReferenceException: Object reference not set to an instance of an object.
10-30 20:25:19.023 I/MonoDroid(12805):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage (Xamarin.Forms.Page page, System.Int32 width, System.Int32 height) [0x00034] in <375f0348c53348fdb7c0a424087b45cb>:0 
10-30 20:25:19.023 I/MonoDroid(12805):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0000a] in <375f0348c53348fdb7c0a424087b45cb>:0 
10-30 20:25:19.023 I/MonoDroid(12805):   at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00018] in <375f0348c53348fdb7c0a424087b45cb>:0 
10-30 20:25:19.023 I/MonoDroid(12805):   at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <241e52499950417a9f098f3fc184c7de>:0 
10-30 20:25:19.023 I/MonoDroid(12805):   at (wrapper dynamic-method) System.Object:28e70870-796b-47c6-a7d7-29a2619bac5a (intptr,intptr,bool,int,int,int,int)
10-30 20:25:19.066 W/art     (12805): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable

I added this file(Build Action to LinkDescription) in my projects:

<linker>
  <assembly fullname="Xamarin.Forms.Platform.Android">
    <type fullname="Xamarin.Forms.Platform.Android.AppCompat.Platform.LayoutRootPage">
      <method name=".ctor" />
    </type>
  </assembly>
</linker>

But I have same exception. I added this item in my csproj:

 <PropertyGroup>
    <AndroidLinkSkip>Xamarin.Android.Support.v7.AppCompat;Xamarin.Forms.Platform.Android</AndroidLinkSkip>
</PropertyGroup>

But I have same exception. Any ideas?

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
FetFrumos
  • 5,388
  • 8
  • 60
  • 98
  • 2
    When you `Link All` be prepared to write your own custom description file. Please also include your Xamarin.Forms version and Xamarin.Android version. You can read up on my blog about the [Linker Analyzer](https://www.jon-douglas.com/2017/09/22/linker-analyzer/) which can help you identify what is being kept between `Link SDK Only` and `Link All`. In short you most likely just want to keep `Link SDK Only` as manually linkskipping your user assemblies is time consuming. Just an FYI, your `linkskip` definition is incorrect, there should be no file extension at the end. – Jon Douglas Oct 30 '17 at 21:29
  • 2
    You should first cast a wide net and ensure your application works with `Link SDK Only`. Once you've done that, move to `Link All` by `linkskipping` each user assembly. Once you've done that, start removing each assembly one-by-one and creating a custom description file for the missing items. – Jon Douglas Oct 30 '17 at 21:31
  • With "Link SDK Only" my app working. I removed .dll from AndroidLinkSkip but I have same exception. – FetFrumos Oct 31 '17 at 05:45
  • 1
    If I use Linker Analyzer - how do I use the received information? I need an example of a working project(Xamarin Forms) with "Link All Assemblies". It would be great.But I did not find it. – FetFrumos Oct 31 '17 at 05:54
  • My blog goes in further detail of how you can use this information. This information will be what is `kept` after the linker is run. Therefore you can use this as a baseline to compare what is not being kept. As for an example of a working project with `Link All Assemblies`, I am not sure off the top of my head as it requires a bit of work. – Jon Douglas Oct 31 '17 at 17:31

0 Answers0