This repository was archived by the owner on Jun 20, 2023. It is now read-only.
 
 
 - 
  Notifications
 
You must be signed in to change notification settings  - Fork 57
 
Setup [assembly: LinkerSafe] for binding projects #77
 
  Closed
 
 
 Conversation
 
 
 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
 Learn more about bidirectional Unicode characters
 
 
 
 
 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.
 
 
 
 dnfclas
 
 
 
 commented
 Nov 16, 2017 
 
 
 
@jonathanpeppers,
Thanks for having already signed the Contribution License Agreement. Your agreement was validated by .NET Foundation. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot
 Redth
 
  
 
 
 Redth
 
 
 suggested changes
 
 
 Nov 30, 2017 
 
 
 
 
 
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. :)
 @jonathanpeppers
 jonathanpeppers
 changed the base branch from
 
 26.1.x
 
 to
 
 27.x
 
 November 30, 2017 19:49  
 
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.
 
 Redth 
 added a commit
 that referenced
 this pull request
 
 Nov 30, 2017 
 
 
 
 
 
 
 
 
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...
 
 Sign up for free
 to subscribe to this conversation on GitHub.
 Already have an account?
 Sign in.
 
 
 Add this suggestion to a batch that can be applied as a single commit.
 This suggestion is invalid because no changes were made to the code.
 Suggestions cannot be applied while the pull request is closed.
 Suggestions cannot be applied while viewing a subset of changes.
 Only one suggestion per line can be applied in a batch.
 Add this suggestion to a batch that can be applied as a single commit.
 Applying suggestions on deleted lines is not supported.
 You must change the existing code in this line in order to create a valid suggestion.
 Outdated suggestions cannot be applied.
 This suggestion has been applied or marked resolved.
 Suggestions cannot be applied from pending reviews.
 Suggestions cannot be applied on multi-line comments.
 Suggestions cannot be applied while the pull request is queued to merge.
 Suggestion cannot be applied right now. Please check back later.
 
 
 
 
Uh oh!
There was an error while loading. Please reload this page.
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 assembliesoption. Since most Xamarin users will have theLink SDK onlyoption 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
TargetFrameworkVersion8.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
zipinfoon the before APK:Here is the results of the after APK with
[assembly: LinkerSafe]:Here is my
packages.config: