Skip to content

[android] don't include .so files in class libraries - #1895

Merged
mattleibow merged 1 commit into
mono:mainfrom
jonathanpeppers:android-class-libraries
Jan 10, 2022
Merged

[android] don't include .so files in class libraries#1895
mattleibow merged 1 commit into
mono:mainfrom
jonathanpeppers:android-class-libraries

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Dec 17, 2021

Copy link
Copy Markdown
Member

Fixes: dotnet/android#5776
Fixes: dotnet/android#6545

If you do:

  1. File -> New Xamarin.Android class library
  2. Add <PackageReference Include="SkiaSharp" Version="2.80.3" />

You end up with 13MB .dll file with C# code inside! The class
library is redistributing the SkiaSharp native libraries.

$(ShouldIncludeNativeSkiaSharp) should default to False for class
libraries.

To test this change, I manually edited:

%userprofile%\.nuget\packages\skiasharp\2.80.3\build\monoandroid1.0\SkiaSharp.targets
%userprofile%\.nuget\packages\skiasharp\2.80.3\buildTransitive\monoandroid1.0\SkiaSharp.targets

Now my class library is 76,800 bytes.

When consuming this class library in an Android application project,
everything should still work as expected. However, the application
will need to reference SkiaSharp -- which is actually ideal.

API Changes

None

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Updated documentation

Fixes: dotnet/android#6545

If you do:

1. File -> New Xamarin.Android class library
2. Add `<PackageReference Include="SkiaSharp" Version="2.80.3" />`

You end up with 13MB `.dll` file with C# code inside! The class
library is redistributing the SkiaSharp native libraries.

`$(ShouldIncludeNativeSkiaSharp)` should default to `False` for class
libraries.

To test this change, I manually edited:

    %userprofile%\.nuget\packages\skiasharp\2.80.3\build\monoandroid1.0\SkiaSharp.targets
    %userprofile%\.nuget\packages\skiasharp\2.80.3\buildTransitive\monoandroid1.0\SkiaSharp.targets

Now my class library is 76,800 bytes.

When consuming this class library in an Android application project,
everything should still work as expected. However, the application
will need to reference SkiaSharp -- which is actually ideal.
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/cc @mattleibow, looks like I don't have permission to add you as reviewer.

@mattleibow

Copy link
Copy Markdown
Contributor

This is a good change because I basically did something like this for HarfBuzzSharp. Previously there was logic to include the native binaries, but was then updated to actually be a no-op - the .targets file is now empty.

In this case, we actually should have done the same and deleted the .targets file. However, we still need to preserve the functionality of the $(ShouldIncludeNativeSkiaSharp) property and make sure it is in the item group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The dll of ClassLibrary too big than ios,i found it pack something from nuget, can i not pack they at debug? Dll size ballooned

2 participants