Xamarin 1.6.1 binding an .aar generates bad code.
After executing these instructions: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-an-aar
I'm available to bind the .aar. The problem is that you can integrate this .aar with by using Android Studio, but not Xamarin framework.
I've added .aar renamed as .txt in attachment to bypass extension validation.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
At start we had this error where generated type was not expected, we can replace this manually before the build.
Severity Code Description Project File Line Suppression State
Error CS0738 'ParceledApiException.Creator' does not implement interface member 'IParcelableCreator.CreateFromParcel(Parcel?)'. 'ParceledApiException.Creator.CreateFromParcel(Parcel)' cannot implement 'IParcelableCreator.CreateFromParcel(Parcel?)' because it does not have the matching return type of 'Object'. Android.Sample.Bind C:\Users\Armands\source\repos\Android.Sample.Bind\Android.Sample.Bind\obj\Debug\generated\src\DE.Fiskal.Connector.Android.Client.Library.Aidl.ParceledApiException.cs 13 Active
Error CS0738 'ParceledApiException.Creator' does not implement interface member 'IParcelableCreator.NewArray(int)'. 'ParceledApiException.Creator.NewArray(int)' cannot implement 'IParcelableCreator.NewArray(int)' because it does not have the matching return type of 'Object[]'. Android.Sample.Bind C:\Users\Armands\source\repos\Android.Sample.Bind\Android.Sample.Bind\obj\Debug\generated\src\DE.Fiskal.Connector.Android.Client.Library.Aidl.ParceledApiException.cs 13 Active
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[Register("android/os/Parcelable$Creator", "", "Android.OS.IParcelableCreatorInvoker")]
[JavaTypeParameters(new string[] { "T" })]
public interface IParcelableCreator : IJavaObject, IDisposable, IJavaPeerable
{
//
// Summary:
// Create a new instance of the Parcelable class.
//
// Parameters:
// source:
// The Parcel to read the object's data from.
//
// Returns:
// To be added.
//
// Remarks:
// Portions of this page are modifications based on work created and shared by the
// Android Open Source Project and used according to terms described in the Creative
// Commons 2.5 Attribution License.
[Register("createFromParcel", "(Landroid/os/Parcel;)Ljava/lang/Object;", "GetCreateFromParcel_Landroid_os_Parcel_Handler:Android.OS.IParcelableCreatorInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
Java.Lang.Object? CreateFromParcel(Parcel? source);
//
// Summary:
// Create a new array of the Parcelable class.
//
// Parameters:
// size:
// Size of the array.
//
// Returns:
// To be added.
//
// Remarks:
// Portions of this page are modifications based on work created and shared by the
// Android Open Source Project and used according to terms described in the Creative
// Commons 2.5 Attribution License.
[Register("newArray", "(I)[Ljava/lang/Object;", "GetNewArray_IHandler:Android.OS.IParcelableCreatorInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
Java.Lang.Object[]? NewArray(int size);
----------------------------------------------------------------------------------------------------
global::DE.Fiskal.Connector.Android.Client.Library.Aidl.ParceledApiException - with what it generated.
public class FccClientStartCallback : Java.Lang.Object, IFccClientStartCallback
{
public void OnError(FccClientError error)
{
//
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Then We have error dispalyed below when we are trying to initalize a calss which implements IFccClientStartCallback, but then when we build t complains about missing methid that is not included in generatred interface.
package crc64361bf24ac458c84b;
public class FccClientStartCallback
extends java.lang.Object
implements
mono.android.IGCUserPeer,
de.fiskal.connector.android.client.library.FccClientStartCallback
{
/** @Hide */
public static final String __md_methods;
static {
__md_methods =
"n_onError:(Lde/fiskal/connector/android/client/library/FccClientError;)V:GetOnError_Lde_fiskal_connector_android_client_library_FccClientError_Handler:DE.Fiskal.Connector.Android.Client.Library.IFccClientStartCallbackInvoker, Android.Sample.Bind\n" +
"";
mono.android.Runtime.register ("Android.Sample.Bind.FccClientStartCallback, Android.Sample.App", FccClientStartCallback.class, __md_methods);
}
public FccClientStartCallback ()
{
super ();
if (getClass () == FccClientStartCallback.class) {
mono.android.TypeManager.Activate ("Android.Sample.Bind.FccClientStartCallback, Android.Sample.App", "", this, new java.lang.Object[] { });
}
}
public void onError (de.fiskal.connector.android.client.library.FccClientError p0)
{
n_onError (p0);
}
private native void n_onError (de.fiskal.connector.android.client.library.FccClientError p0);
private java.util.ArrayList refList;
public void monodroidAddReference (java.lang.Object obj)
{
if (refList == null)
refList = new java.util.ArrayList ();
refList.add (obj);
}
public void monodroidClearReferences ()
{
if (refList != null)
refList.clear ();
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Severity Code Description Project File Line Suppression State
Error error: crc64361bf24ac458c84b.FccClientStartCallback is not abstract and does not override abstract method onSuccess(FccAndroid) in de.fiskal.connector.android.client.library.FccClientStartCallback
public class FccClientStartCallback Android.Sample.App C:\Users\Armands\source\repos\Android.Sample.Bind\Android.Sample.App\obj\Debug\120\android\src\crc64361bf24ac458c84b\FccClientStartCallback.java 4
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Possible Solution as discussed
The 1.st error contains two sub errors:
Error CS0738 'ParceledApiException.Creator' does not implement interface member 'IParcelableCreator.CreateFromParcel(Parcel?)'. 'ParceledApiException.Creator.CreateFromParcel(Parcel)' cannot implement 'IParcelableCreator.CreateFromParcel(Parcel?)' because it does not have the matching return type of 'Object'. Android.Sample.Bind C:\Users\Armands\source\repos\Android.Sample.Bind\Android.Sample.Bind\obj\Debug\generated\src\DE.Fiskal.Connector.Android.Client.Library.Aidl.ParceledApiException.cs 13 Active
Error CS0738 'ParceledApiException.Creator' does not implement interface member 'IParcelableCreator.NewArray(int)'. 'ParceledApiException.Creator.NewArray(int)' cannot implement 'IParcelableCreator.NewArray(int)' because it does not have the matching return type of 'Object[]'. Android.Sample.Bind C:\Users\Armands\source\repos\Android.Sample.Bind\Android.Sample.Bind\obj\Debug\generated\src\DE.Fiskal.Connector.Android.Client.Library.Aidl.ParceledApiException.cs 13 Active
The error is that it cannot cast DE.Fiskal.Connector.Android.Client.Library.Aidl.ParceledApiException
to Java.Lang.Object
and that is why we just replace them and I do not expect any runtime issues because of that.
2nd Error:
Error error: crc64361bf24ac458c84b.FccClientStartCallback is not abstract and does not override abstract method onSuccess(FccAndroid) in de.fiskal.connector.android.client.library.FccClientStartCallback
public class FccClientStartCallback Android.Sample.App C:\Users\Armands\source\repos\Android.Sample.Bind\Android.Sample.App\obj\Debug\120\android\src\crc64361bf24ac458c84b\FccClientStartCallback.java 4
The error states that in generated java the onSuccess method is missing. It genareted that class from the .cs class that implements IFccClientStartCallback. Expect code generator to generate that missing method on cs interface. If we write down the blank method in the generated class we can build it further.
Are there any suggestions from Microsoft to fix this by using: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/customizing-bindings/java-bindings-metadata