Hello,
Welcome to our Microsoft Q&A platform!
You can try to set the linker option to None
and try again , just as follows:
For more details , you can check Linking on Android.
The linker employs static analysis of the project's code to determine which types, methods, fields, or properties are in use and then strips any unused types, methods, fields, or properties from the final assembly, reducing the size by not having any unused code in the final assembly. On the assembly level, if no code from an assembly is used, the entire assembly will be omitted regardless of the Linker setting. It is worth noting that static code analysis will not pick up types used via reflection. This is not generally an issue with framework SDKs as they are optimized to check for this, but if you link user assemblies and use reflection to access types, etc, from the user assemblies, then you may need to explicitly preserve those types, etc, in the user assembly.
For example:
- You might have code that you call dynamically via System.Reflection.MemberInfo.Invoke.
- If you instantiate types dynamically, you may want to preserve the default constructor of your types.
- If you use XML serialization, you may want to preserve the properties of your types.
In these cases, you can use the Android.Runtime.Preserve attribute.
For more details,check: https://learn.microsoft.com/en-us/xamarin/android/deploy-test/linker
Best Regards,
Jessie Zhang
---
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.