-
Notifications
You must be signed in to change notification settings - Fork 533
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
Add NugetPackageId Metadata to TaskItems #9559
Conversation
src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs
Outdated
Show resolved
Hide resolved
faea51c
to
9bc94c4
Compare
9bc94c4
to
eaf23a3
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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.
Is there a test that checks XA0141
? Maybe it could assert the new message?
It doesn't look like there is an existing test. I'm not sure how we could trigger the error unless we have a Nuget with a non 16bit aligned native library. Maybe an old version of Skia will work. |
This version should trigger the error https://github.com/mono/SkiaSharp/releases/tag/v3.116.0 |
2fe790f
to
ee42973
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
The unit test has thrown up some issues. |
/azp run |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
Dictionary initializers for the win!
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Draft commit message: Fixes: https://github.com/dotnet/android/issues/9544
Context: 64bb147f2ead5bd403a823d27b33f590197477fa
[Google announced][0] that future versions of Android would require
that native libraries use 16 KB page sizes on arm64. At present, the
timeline for *when* 16 KB page sizes will be required is unknown,
though we assume it will be with Android 16 or later.
In order to get ahead of this, .NET 9 added an XA0141 warning in
64bb147f.
The problem is, this warning is not entirely actionable:
dotnet new android
dotnet add package Xamarin.GooglePlayServices.Vision.Face.Contour.Internal --version 116.1.0.19
dotnet build -c Release
results in:
warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so'
which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details
warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so'
which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details
What are customers supposed to *do* with this?
The original assumption was that the NuGet package and Version would
be available as metadata items on the MSBuild Items. Unfortunately
that was not the case, so the data the user gets is empty.
Add the required metadata to all NuGet Package references resolved by
the project. This will allow us to propagate that data throughout
the build Items as they are transformed. This means we can provide a
decent error message to the user:
warning XA0141: Android 16 will require 16 KB page sizes, Shared library 'libface_detector_v2_jni.so' does not have a 16 KB page size.
Please inform the authors of the NuGet package 'Xamarin.GooglePlayServices.Vision.Face.Contour.Internal' version '116.1.0.19'
which contains '/Users/xxx/.nuget/packages/xamarin.googleplayservices.vision.face.contour.internal/116.1.0.19/lib/net8.0-android34.0/play-services-vision-face-contour-internal.aar'.
See https://developer.android.com/guide/practices/page-sizes for more details.
[0]: https://android-developers.googleblog.com/2024/08/adding-16-kb-page-size-to-android.html |
Re-reading the message "Shared library 'libface_detector_v2_jni.so' must use 16 KB page sizes" with "fresher" eyes implies that this must be fixed now, which isn't quite true. It's fine now; it won't be fine in some future Android version, currently unknown though assumed to be after Android 16. Perhaps we should do:
|
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
For the example project this is the new error message
|
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Looks like Android 16 may be requiring 16KB page sizes, e.g. API-35 emulators are requiring 16KB page size: mono/SkiaSharp#3025 (comment) |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Figuring out how to fix a
XA0141
error is almost impossible for an end user at this time. The default error message isthe assumption was that the NuGet package and Version would be available as metadata items on the
MSBuild Items. Unfortunately that was not the case, so the data the user gets is empty.
This commit adds the required Metadata to all NuGet Package references resolved by the project. This will allow us to propagate that data throughout the build Items as they are transformed. This will in the end mean we can provide a decent error message to the user.