1

I have a Xamarin Forms app with a corresponding Xamarin Android project. I use Azure Notification Hub for managing pushes to the app and FCM for the Android piece. The app has been functional for a while in the above setup.

Everything works great with the app when the Linker is set to "None" but the final download size of my app is huge. Setting the Linker property to SDK Assemblies Only does not cause any build errors but causes the push notifications to break. When a notification is pushed to the device the app crashes (foreground or background).

The error I log with Firebase Crashlytics is java.lang.InstantiationException: java.lang.Class<com.google.firebase.iid.FirebaseInstanceIdReceiver> cannot be instantiated. I understand the Linker probably removed "unused" classes one of which is probably the required Firebase class.

I have tried adding various modifications of namespaces, class names, assembly names, etc to the Skip Linking assemblies option and none seem to help with the issue

enter image description here

I am also trying to Enable MultiDex on this app, but without the linker, it crashes the app on initial load. With the Linker Enabled, Multi-Dex seems to work fine as well.

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
Ron
  • 886
  • 13
  • 39
  • 1
    The None setting is not usually recommended for production builds. The linker will sometimes remove code that you want to preserve. You could use the Android.Runtime.Preserve attribute to preserve. https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker – Wendy Zang - MSFT Oct 26 '20 at 06:45

0 Answers0