Skip to content

Issues Binding a library Library after AndroidX migration #4955

Closed

Description

@FANMixco

I'm having some issues with a library that I upgraded:

https://github.com/SupernovaIC/OMFM

It works properly in Android Studio:

But when I binding it, I'm getting very strange warnings and I'm not sure what I'm missing, I added the following NuGets:

My previous library is here:

https://www.nuget.org/packages/Xamarin-OneMoreFabMenu/

Steps to Reproduce

  1. Download this repo.
  2. Build it or rebuild it.

Expected Behavior

To build without any strange warning.

Actual Behavior

It builds with the following warnings:

1>------ Rebuild All started: Project: Xamarin-OneMoreFabMenu, Configuration: Release Any CPU ------
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(141,5): warning XA4231: The Android class parser value 'jar2xml' is deprecated and will be removed in a future version of Xamarin.Android. Update the project properties to use 'class-parse'.
1>JARTOXML : warning J2XA006: missing class error was raised while reflecting com.dekoservidoni.omfm.OneMoreFabMenu : kotlin/jvm/internal/DefaultConstructorMarker
1>JARTOXML : OpenJDK 64-Bit Server VM warning : ignoring option UseSplitVerifier; support was removed in 8.0
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(372,5): warning MSB6002: The command-line for the "BindingsGenerator" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "BindingsGenerator" into multiple calls with fewer parameters per call.
1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabMenu not found for nested type Com.Dekoservidoni.Omfm.OneMoreFabMenu._1.
1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabMenu not found for nested type Com.Dekoservidoni.Omfm.OneMoreFabMenu.IOptionsClick.
1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabMenu not found for nested type Com.Dekoservidoni.Omfm.OneMoreFabMenu.FabClickListener._1.
1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabMenu not found for nested type Com.Dekoservidoni.Omfm.OneMoreFabMenu.Hide._1.
1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabMenu not found for nested type Com.Dekoservidoni.Omfm.OneMoreFabMenu.HideMenu._1.
1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabMenu not found for nested type Com.Dekoservidoni.Omfm.OneMoreFabMenu.OnMeasure._1.
1>BINDINGSGENERATOR : warning BG8800: Unknown parameter type com.dekoservidoni.omfm.OneMoreFabMenu in method OnNestedPreScroll in managed type Com.Dekoservidoni.Omfm.Utils.OneMoreFabScrollBehaviour.
1>BINDINGSGENERATOR : warning BG8800: Unknown parameter type com.dekoservidoni.omfm.OneMoreFabMenu in method OnStartNestedScroll in managed type Com.Dekoservidoni.Omfm.Utils.OneMoreFabScrollBehaviour.
1> Xamarin-OneMoreFabMenu -> C:\Users\feder\source\repos\Xamarin-OneMoreFabMenu\Xamarin-OneMoreFabMenu\bin\Release\Xamarin-OneMoreFabMenu.dll

Version Information

Visual Studio 2019, 16.7.0 Preview 5.0

Activity

  1. jpobst commented on Jul 23, 2020

    @jpobst
    Contributor

    It seems like it is building fine, does it work? Warnings are pretty much a way of life when binding libraries. Generally they represent things the tooling could not automatically do. If you do not care about the API it could not bind automatically then you can ignore them. If you do need that API you will generally need to use "metadata" to help the tooling understand what to do:

    https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata

    This one should be easy to fix by following the instructions:

    warning XA4231: The Android class parser value 'jar2xml' is deprecated and will be removed in a future version of Xamarin.Android. Update the project properties to use 'class-parse'.
    

    This one will probably go away when you switch to class-parse, as we only added Kotlin support to class-parse:

    warning J2XA006: missing class error was raised while reflecting com.dekoservidoni.omfm.OneMoreFabMenu : kotlin/jvm/internal/DefaultConstructorMarker
    

    This one is something we need to fix now that AndroidX breaks things down into tons of tiny packages:

    warning MSB6002: The command-line for the "BindingsGenerator" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "BindingsGenerator" into multiple calls with fewer parameters per call.
    

    If you are referencing NuGet packages you do not need, removing them might make it go away.

  2. added this to the Under Consideration milestone on Jul 23, 2020
  3. FANMixco commented on Jul 23, 2020

    @FANMixco
    Author

    It seems like it is building fine, does it work? Warnings are pretty much a way of life when binding libraries. Generally they represent things the tooling could not automatically do. If you do not care about the API it could not bind automatically then you can ignore them. If you do need that API you will generally need to use "metadata" to help the tooling understand what to do:

    https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata

    This one should be easy to fix by following the instructions:

    warning XA4231: The Android class parser value 'jar2xml' is deprecated and will be removed in a future version of Xamarin.Android. Update the project properties to use 'class-parse'.
    

    This one will probably go away when you switch to class-parse, as we only added Kotlin support to class-parse:

    warning J2XA006: missing class error was raised while reflecting com.dekoservidoni.omfm.OneMoreFabMenu : kotlin/jvm/internal/DefaultConstructorMarker
    

    This one is something we need to fix now that AndroidX breaks things down into tons of tiny packages:

    warning MSB6002: The command-line for the "BindingsGenerator" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "BindingsGenerator" into multiple calls with fewer parameters per call.
    

    If you are referencing NuGet packages you do not need, removing them might make it go away.

    Hi, the number one is tricky because I chose this option because the class-parse option doesn't give you any hint about the potential issues. I'd expand the class-parse before deprecating it.

    The ones I chose are because they exist in the original project that I upgraded and I'm almost convinced they're required because it's not the first library I have bound.

    I guess I'm missing one library or something should be extended, any hint?

  4. jpobst commented on Jul 23, 2020

    @jpobst
    Contributor

    What potential issues are you referring to for class-parse? jar2xml has been deprecated for several years now, and the default for new binding projects has been class-parse for several years as well.

  5. FANMixco commented on Jul 23, 2020

    @FANMixco
    Author

    What potential issues are you referring to for class-parse? jar2xml has been deprecated for several years now, and the default for new binding projects has been class-parse for several years as well.

    This is the result of the class-parse:

    1>------ Rebuild All started: Project: Xamarin-OneMoreFabMenu, Configuration: Release Any CPU ------
    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(327,5): warning MSB6002: The command-line for the "BindingsGenerator" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "BindingsGenerator" into multiple calls with fewer parameters per call.
    1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.targets(372,5): warning MSB6002: The command-line for the "BindingsGenerator" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "BindingsGenerator" into multiple calls with fewer parameters per call.
    1>BINDINGSGENERATOR : warning BG8604: top ancestor OneMoreFabUtils not found for nested type Com.Dekoservidoni.Omfm.Utils.OneMoreFabUtils.Direction.
    1>  Xamarin-OneMoreFabMenu -> C:\Users\feder\source\repos\Xamarin-OneMoreFabMenu\Xamarin-OneMoreFabMenu\bin\Release\Xamarin-OneMoreFabMenu.dll
    ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
    

    It's very unclear about the issue, the java2xml is way more descriptive of where potentially is the issue. I don't use it for the final release, but to track where the issue can be.

  6. jpobst commented on Jul 23, 2020

    @jpobst
    Contributor

    The warning produced by class-parse is completely different than the ones produced by jar2xml. Fixing one will not fix the other.

    This is because they use completely different mechanisms for reading the .jar file to determine what to bind.

    The class-parse warning is having an issue with binding Com.Dekoservidoni.Omfm.Utils.OneMoreFabUtils.Direction. Since this enum does not seem to be used anywhere, I would suggest ignoring the warning.

  7. FANMixco commented on Jul 24, 2020

    @FANMixco
    Author

    The warning produced by class-parse is completely different than the ones produced by jar2xml. Fixing one will not fix the other.

    This is because they use completely different mechanisms for reading the .jar file to determine what to bind.

    The class-parse warning is having an issue with binding Com.Dekoservidoni.Omfm.Utils.OneMoreFabUtils.Direction. Since this enum does not seem to be used anywhere, I would suggest ignoring the warning.

    I don't think so because they're used in the main class OneMoreFabMenu:

    Between line 140 and 153:

    image

    Line 346:

    image

    I have noticed very strange behaviors with Enums in general since it's not the first time that I have faced something similar.

  8. jpobst commented on Jul 24, 2020

    @jpobst
    Contributor

    While the Direction enum is used within the library, it is not publicly exposed. It is defined here, as a public enum inside an internal class:

    https://github.com/SupernovaIC/OMFM/blob/master/omfm/src/main/java/com/dekoservidoni/omfm/utils/OneMoreFabUtils.kt#L8

    The issue is we are ignoring the OneMoreFabUtils class because it is internal, but we are not ignoring the Direction enum like we should. Then when we are building our model of the types we try to nest the enum in the class, but we cannot find the class because we ignored it.

    The easiest way to remove the warning is to simply remove the Direction enum as it is not intended to be public and not needed by the binding:

    <remove-node path="/api/package[@name='com.dekoservidoni.omfm.utils']/class[@name='OneMoreFabUtils.Direction']" />
    
  9. jpobst commented on Jul 24, 2020

    @jpobst
    Contributor

    Filed fixing the warning as dotnet/java-interop#682.

  10. jpobst commented on Aug 17, 2020

    @jpobst
    Contributor

    Hopefully this got you unstuck! Closing this in favor of dotnet/java-interop#682.

  11. ghost locked as resolved and limited conversation to collaborators on Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: BindingsIssues in Java Library Binding projects.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions