Repository navigation
Issues Binding a library Library after AndroidX migration #4955
Description
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
- Download this repo.
- 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
jpobst commentedon Jul 23, 2020
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:
This one will probably go away when you switch to
class-parse, as we only added Kotlin support toclass-parse:This one is something we need to fix now that AndroidX breaks things down into tons of tiny packages:
If you are referencing NuGet packages you do not need, removing them might make it go away.
FANMixco commentedon Jul 23, 2020
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?
jpobst commentedon Jul 23, 2020
What potential issues are you referring to for
class-parse?jar2xmlhas been deprecated for several years now, and the default for new binding projects has beenclass-parsefor several years as well.FANMixco commentedon Jul 23, 2020
This is the result of the class-parse:
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.
jpobst commentedon Jul 23, 2020
The warning produced by
class-parseis completely different than the ones produced byjar2xml. Fixing one will not fix the other.This is because they use completely different mechanisms for reading the
.jarfile to determine what to bind.The
class-parsewarning is having an issue with bindingCom.Dekoservidoni.Omfm.Utils.OneMoreFabUtils.Direction. Since this enum does not seem to be used anywhere, I would suggest ignoring the warning.FANMixco commentedon Jul 24, 2020
I don't think so because they're used in the main class
OneMoreFabMenu:Between line 140 and 153:
Line 346:
I have noticed very strange behaviors with
Enumsin general since it's not the first time that I have faced something similar.jpobst commentedon Jul 24, 2020
While the
Directionenum is used within the library, it is not publicly exposed. It is defined here, as apublicenum inside aninternalclass: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
OneMoreFabUtilsclass because it isinternal, but we are not ignoring theDirectionenum 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
Directionenum as it is not intended to be public and not needed by the binding:jpobst commentedon Jul 24, 2020
Filed fixing the warning as dotnet/java-interop#682.
jpobst commentedon Aug 17, 2020
Hopefully this got you unstuck! Closing this in favor of dotnet/java-interop#682.
[Xamarin.Android.Tools.Bytecode] Hide Kotlin nested types inside (#723)
[Xamarin.Android.Tools.Bytecode] Hide Kotlin nested types inside (#723)