Android Xamarin AAR Binding enclosing type

589 Views Asked by At

I have an .aar third party library that I want to use in Xamarin Android. So I created a new Android Bindings Library, added the aar-library and changed the Build action of the aar file to LibraryProjectZip like described here: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-an-aar

Nothing else was changed and I would expect the project to compile and generate a dll file. Instead I get a lot of errors saying Error CS0542 'xy': member names cannot be the same as their enclosing type. When I jump to the origin of the error, I find the errors in generated code by Visual Studio with the classes looking something like:

public abstract class Albumin : Java.Lang.Object {

    internal Albumin ()
    {
    }

    // (removed for readability)
    [Register ("ALBUMIN")]
    public const string Albumin = (string) "albumin";

I cannot modify the source code of the library. What can I do in order to build the Binding Library successfully?

1

There are 1 best solutions below

0
On

Thank you very much @Leo Zhu for the answer in the comments:

The solution is Renaming Members. So in my case the Metadata.xml in die Binings Library would look like the following:

<attr path="/api/package[@name='com.company.android.sdk.dataclass']/interface[@name='DataClass.Albumin']/field[@name='ALBUMIN']" name="name">ALBUMIN_Binding</attr>