New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup [assembly: LinkerSafe] for binding projects #77
Conversation
I discovered there was some file size that could be spared from the support library assemblies in release APKs by using the `Link all assemblies` option. Since most Xamarin users will have the `Link SDK only` option set, we can save most Xamarin developers some APK size by setting up the `[assembly: LinkerSafe]` attribute in the support libraries. To get an idea on what this saves, I tested the default Xamarin.Forms template in VS for Mac. I then upgraded to `TargetFrameworkVersion` 8.0, API 26, Xamarin.Forms 2.5.0, and 26.1.0.1 support libraries. Before: - Support libs: 5231104 - APK: 20948533 After `[assembly: LinkerSafe]`: - 2357248 - 17312534 It appears this change saves ~3.6MB in APK file size in release mode for the default Xamarin.Forms template.
@jonathanpeppers, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you PR against 27.x branch instead? We're going to try including this in the QA cycle for the 27 release first. :)
Yeah, no problem. Looks like I'll have to rework this a bit, though. Conflicts! |
Ahh i can just work it in manually then, just thought if it merged nicely I'd ask you to do it. |
See the original PR #77 by @jonathanpeppers Basically we can enable these assemblies to be linked when projects are set to Link SDK Assemblies only. This can always be opted out of by specifying `AndroidLinkSkip` in your .csproj’s: ``` <PropertyGroup> <AndroidLinkSkip>Xamarin.Android.Support.Compat;Xamarin.Android.Support.Compat.UI;...</AndroidLinkSkip> </PropertyGroup> ```
Manually adding this... |
Support Libraries Version (eg: 23.3.0):
26.1.0.1
Does this change any of the generated binding API's?
Nope
Describe your contribution
I discovered there was some file size that could be spared from the
support library assemblies in release APKs by using the
Link all assemblies
option. Since most Xamarin users will have theLink SDK only
option set, we can save most Xamarin developers some APK size bysetting up the
[assembly: LinkerSafe]
attribute in the supportlibraries.
To get an idea on what this saves, I tested the default Xamarin.Forms
template in VS for Mac. I then upgraded to
TargetFrameworkVersion
8.0, API 26, Xamarin.Forms 2.5.0, and 26.1.0.1 support libraries.
Before:
After
[assembly: LinkerSafe]
:It appears this change saves ~3.6MB in APK file size in release mode
for the default Xamarin.Forms template. The app still seemed to work fine,
it appears we can just get this file size for free!
Further details
Here is the results of
zipinfo
on the before APK:Here is the results of the after APK with
[assembly: LinkerSafe]
:Here is my
packages.config
: