I'm trying to learn how to make Android Bindings for my .NET MAUI project, in particular the library for Facebook Login, in VS 2022 17.8.4.
This binding already exists in Facebook Components but it's outdated so I'm trying to create the binding for the latest version 16.3.0
core-ctx
facebook-login 16.3.0 -> facebook-core 16.3.0 -> core-ctx 1.3.2
(core-ctx exists as NuGet but not this version)So I download AAR for core-ctx 1.3.2
and I create the binding library for it.
core-ctx 1.3.2
has dependencies that exist as NuGets so I include those.
CSPROJ references
<PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.1.0.9" />
<PackageReference Include="Xamarin.AndroidX.Core" Version="1.3.2.3" />
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="1.3.72" />
So at this step I understand that this job is not yet done and I have to start working on the XML additions and transforms from Java to C#.
So I prepare:
Please also note I know next to nothing about Java.
This is the MSBuild output
>obj\Debug\net8.0-android\api.xml.class-parse : warning BG8605: The Java type '$' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\tools\Xamarin.Android.Bindings.ClassParse.targets(43,5): obj\Debug\net8.0-android\api.xml.class-parse warning BG8605: The Java type '$' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
1>obj\Debug\net8.0-android\java-resolution-report.log : warning BG8606: Some types or members could not be bound because referenced Java types could not be found. See the 'java-resolution-report.log' file for details.
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\34.0.52\tools\Xamarin.Android.Bindings.ClassParse.targets(43,5): obj\Debug\net8.0-android\java-resolution-report.log warning BG8606: Some types or members could not be bound because referenced Java types could not be found. See the 'java-resolution-report.log' file for details.
This does not say much so I open the java-resolution-report.log
and the file has first line saying:
The method '[Method] android.animation.Animator.AnimatorListener addListener$default(android.animation.Animator obj, kotlin.jvm.functions.Function1 onEnd, kotlin.jvm.functions.Function1 onStart, kotlin.jvm.functions.Function1 onCancel, kotlin.jvm.functions.Function1 onRepeat, int p5, java.lang.Object p6)' was removed because its name contains a dollar sign.
There's like 40 lines all having the same message, that there is a method that was removed because it contained a dollar sign.
Great! So I have to somehow write the transformation that removes the dollar sign I guess.
So I open the java decompiler, I look at android.animation.Animator.AnimatorListener addListener$default
... but there is no method named addListener$default
.
There is method addListener
so I don't understand why MSBUILD detected a method with a dollar sign if the decompilation does not show any such method?
I've looked at different lines and the java decompilation never contains such a method that has a dollar sign. Although the decompilation shows local variables with a dollar signs but nothing named addListener$default
So why is MSBUILD reporting an error about something I cannot see in the decompilation file? What am I missing?
The $
symbol in the stack trace indicates that it was a native method that was invoked. E.g., rather than it being implemented in Java bytecode, it is implemented natively. Since you're decompiling the SDK, you won't see those native methods implemented there. They'd be implemented in the NDK, in C and/or C++.
This is useful for performance but can make problems originating in native methods difficult to debug.
If you'd want to go a step further, you would want to decompile the Android NDK as well. Or, you may find your answers simply by reading documentation. I would point you in the direction of that if I could find any documentation relevant to the problem you're having, but I haven't been able to.