Xamarin.Android Binding Library

nnovalbos 371 Reputation points
2021-03-05T12:20:59.293+00:00

Hi,

I am trying to use a native Android library in Xamarin.forms

I'm having compilation issues that I haven't been able to fix by editing the Metadata.xml

The problem comes in that the native library has an abstract class A, another abstract class B that inherits from A and a class C that inherits from B

Class A has an abstract method: public abstract byte [] flush ()

Class B inherits it but does not implement it: public abstract byte [] flush []

Class C already implements the method.

The issue is that the compilation result is wrong, the C # conversion of class B does not add the 'override' to the flush method.

To solve this, I added in the file "metadata.xml" an 'att' that modifies the visibility to the flush method:

<att path = ".. package ../ class ../ method" name = "visibility"> public override </att>

This fixes this problem but duplicates the word 'override' in one place.

The compilation of the library generates the class 'B' in C #, which has the flush method, to which 'override' has been added and it is correct. But the compilation has also generated a class 'BInvoker', which inherits from B and in this case that flush method already had the override, so it duplicates it and gives a compilation error: "duplicate override"

Is there a way to work around this in the Metadata or EnumMethods.xml? Currently for it to compile I have to remove the 'override' manually.

Thanks a lot

Developer technologies .NET Xamarin
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.