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

Type-forwarding for binding libraries #807

Closed
JensSchadron opened this issue Oct 27, 2023 · 3 comments · Fixed by #863
Closed

Type-forwarding for binding libraries #807

JensSchadron opened this issue Oct 27, 2023 · 3 comments · Fixed by #863
Labels
enhancement Proposed change to current functionality

Comments

@JensSchadron
Copy link

Android application type

Android for .NET (net6.0-android, etc.)

Affected platform version

.NET 8 RC2

Description

After having binded the com.airbnb.android:lottie android package, I stumbled upon an issue where the AOT compiler would crash due to not being able to resolve the assembly of AndroidX.Collection. After further investigation, I noticed that the binding library was bound using version 1.2.0.6 of Xamarin.AndroidX.Collection while my consuming project was using version 1.3.0.1 of said package. However, since version 1.3.0 of said package, all types have been moved to the Xamarin.AndroidX.Collection.Jvm package, but (seemingly?) no type forwards have been set up on the original package, breaking all binding projects that had been compiled against an older version of the package.

This all being said, I think this issue could be avoided by adding type-forwards on the binding library, but I'm not sure at all how feasible that would be.

Steps to Reproduce

  1. Create a binding library that uses Xamarin.AndroidX.Collection >1.3.* (or build for example this PR: Add Maui support Baseflow/LottieXamarin#379)
  2. Consume the compiled binding project in a project that requires Xamarin.AndroidX.Collection <=1.3.*
  3. Compile using AOT

Did you find any workaround?

  1. Recompile the binding library with the newer 1.3+ version of Xamarin.AndroidX.Collection package
  2. Lower the required version in the consuming library (not feasible in my project due to other dependencies)

Relevant log output

##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Precompiling failed for /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm64/linked/Lottie.Android.dll with exit code 139. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Precompiling failed for /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm64/linked/Lottie.Android.dll with exit code 139. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Mono Ahead of Time compiler - compiling assembly /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm64/linked/Lottie.Android.dll [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Mono Ahead of Time compiler - compiling assembly /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm64/linked/Lottie.Android.dll [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : AOTID EAF5C8D7-F208-0459-65B9-28DDA7291B67 [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : AOTID EAF5C8D7-F208-0459-65B9-28DDA7291B67 [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Using profile data file '/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/dotnet.aotprofile' [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Using profile data file '/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/dotnet.aotprofile' [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Added 0 methods from profile. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Added 0 methods from profile. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Could not load signature of Com.Airbnb.Lottie.LottieComposition:Init due to: Could not load file or assembly 'Xamarin.AndroidX.Collection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Could not load signature of Com.Airbnb.Lottie.LottieComposition:Init due to: Could not load file or assembly 'Xamarin.AndroidX.Collection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Precompiling failed for /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm/linked/Lottie.Android.dll with exit code 139. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Precompiling failed for /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm/linked/Lottie.Android.dll with exit code 139. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Mono Ahead of Time compiler - compiling assembly /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm/linked/Lottie.Android.dll [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Mono Ahead of Time compiler - compiling assembly /Users/runner/work/1/s/src/DriverApp/Droid/obj/Integration/net7.0-android/android-arm/linked/Lottie.Android.dll [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : AOTID 21C1E193-9179-D655-1B09-8A64EFF31798 [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : AOTID 21C1E193-9179-D655-1B09-8A64EFF31798 [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Using profile data file '/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/dotnet.aotprofile' [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Using profile data file '/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/dotnet.aotprofile' [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Added 0 methods from profile. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Added 0 methods from profile. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
##[error]/Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Could not load signature of Com.Airbnb.Lottie.LottieComposition:Init due to: Could not load file or assembly 'Xamarin.AndroidX.Collection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
14:23:14 [ERR] /Users/runner/.dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.95/targets/Microsoft.Android.Sdk.Aot.targets(91,5): error : Could not load signature of Com.Airbnb.Lottie.LottieComposition:Init due to: Could not load file or assembly 'Xamarin.AndroidX.Collection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. [/Users/runner/work/1/s/src/DriverApp/Droid/Driver.Droid.csproj]
@moljac
Copy link
Member

moljac commented Nov 1, 2023

@JensSchadron
Thanks for the feedback.

Google moving types around problem is not new

#764

but we hit it more often in last 4-6 months (some libraries got Jvm suffix and types were moved).

Type forwarding is solution for API breakage in .NET world and it would help for cases like this one. Google is not that strict with their APIs:

  • breaking APIs
  • dependencies in preview

Does Android native world has "type forwarding"? I am not aware of it. So, we are in the same situation as Android devs. Improvements (nice-to-haves) would be great, but I am not sure we'll be able to implement it very soon.

  • We/I bind+maintain 289+278 (I think) packages.
  • I am not expert for all APIs
  • When binding is done I don't know how much of the API was bound (I hope it is close to 100%)
  • even if I'd have time now to work on samples - they would not prove 100% original API covering
  • I don't know what google moved, so question is what to forward? Everything?
  • Will forwarding cause other issues like duplicates because of version mismatches?

We'll discuss it, but...

@moljac moljac added enhancement Proposed change to current functionality needs-triage dependencies Pull requests that update a dependency file labels Nov 1, 2023
@PavloLukianets
Copy link

PavloLukianets commented Nov 7, 2023

+1 here. @JensSchadron instead of binding lottie try to use SkiaSharp.Extened.UI

@jpobst
Copy link
Contributor

jpobst commented Mar 15, 2024

This should be fixed with the latest version of Xamarin.AndroidX.Collection:
https://www.nuget.org/packages/Xamarin.AndroidX.Collection/1.4.0.2

Note this does not imply that we have tooling that can automatically detect these cases or that we will be proactive about adding type forwards, but we can manually add reported instances that are problematic like this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Proposed change to current functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants