Skip to content
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

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

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Dec 17, 2021

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
Member Author

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

@mattleibow
Copy link
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.

@mattleibow mattleibow merged commit d4dbf39 into mono:main Jan 10, 2022
@jonathanpeppers jonathanpeppers deleted the android-class-libraries branch January 10, 2022 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants