Xamarin Android Binding Library Custom Namespace Not Recognized

1k Views Asked by At

I am creating a Xamarin Android binding library for an existing JAR that contains a single class and following the Xamarin binding library documentation, I am able to successfully rename the namespace using:

<attr path="/api/package[@name='com.company.blah']" name="managedName">Company.Blah</attr>

I also confirmed the namespace is changed in the generated class in the 'obj/Debug' folder:

namespace Company.Blah {

    // Metadata.xml XPath class reference: path="/api/package[@name='com.company.blah']/class[@name='NativeClass']"
    [global::Android.Runtime.Register ("com/sprylab/android/widget/TextureVideoView", DoNotGenerateAcw=true)]
    public partial class NativeClass 
    {
        ...
    }
}

I face two problems:

  1. I am unable to reference NativeClass from a sample Android project. It's like to doesn't see the namespace at all. The binding project built successfully without errors.
  2. If I remove the package namespace rename setting, it also builds successfully and I am then able to reference it in my sample project but it requires that I fully qualify the class name anywhere it is used:

    private com.company.blah.NativeClass nativeClass;

I'm hoping if I can fix #1, then #2 will not show up again. If so, I'm also curious how you prevent fully qualified class names from showing up?

1

There are 1 best solutions below

0
On BEST ANSWER

Going into the project settings of the binding library project and clearing the box to the right of the assembly name seemed to do the trick. Looking inside the csproj directly, it is the root namespace.

MyAssembly.csproj Properties