Generated C# classes not nesting java classes correctly RRS feed

  • Question

  • User356177 posted

    I am trying to Bind the Poynt SDK to C# Using Xamarin's binding library. The .aar file is public for anyone who wants to recreate this

    I am having a problem binding the .aar file, after building the solution the classes aren't being nested properly.

    IPoyntProductCatalogWithProductListener is an interface that is supposed to contain a nested Stub class that contains a nested Proxy class. Instead the Stub and Proxy are outside of the interface.

    I am following the java example app for reference, this is the code I am trying to replicate:

    private IPoyntProductCatalogWithProductListener mProdCatWithProdListener = new IPoyntProductCatalogWithProductListener.Stub() {
        public void onResponse(CatalogWithProduct catalogWithProduct, PoyntError poyntError) throws RemoteException {
            StringBuilder output = new StringBuilder();
            // products not nested inside a category
            for (CatalogItemWithProduct catalogItem : catalogWithProduct.getProducts()){
                Product product = catalogItem.getProduct();
                output.append("---- ITEM -----\n");
                output.append("Product Name: " + product.getName() + "\n");
                output.append("Product Id: " + product.getId() + "\n");
                output.append("Product Price: " + product.getPrice().getAmount() + "\n");
                Log.d(TAG, "\n"+output);

    } };

    As you can see I can't do "IPontProductCatalogWithProductListener.Stub" because it isn't nested. Is there a way I can edit the metadata file so it forces these nested classes. Or is there a work around?

    Friday, December 1, 2017 6:58 PM

All replies

  • User180523 posted

    There are some transforms you can define in XML to adjust how the binding libraries are handled. Most commonly I make a point of giving real names to the auto-generated parameters p0 and p1 etc. Next often I sometimes have to update the type of properties or returns. Sometimes you have to rename fields because C# has different naming conventions/restrictions than Java.

    I'll bet that what's happening is that a name/namespace is getting translated badly so everything downstream of that operation (like nesting) gets broken. Before you take the long road of making 100 changes you might find one thing to fix earlier in the process that keeps the rest of the problems from happening.

    Friday, December 1, 2017 7:19 PM
  • User356177 posted

    I have opened the .aar file and it has the names stored as IPoyntProductCatalogWithProductListener, IPoyntProductCatalogWithProductListener$Stub, IPoyntProductCatalogWithProductListener$Stub$Proxy

    I know that this can cause obfuscated cases but I added a line in my metadata setting that to false. I opened the api.xml and it has it as IPoyntProductCatalogWithProductListener.Stub but in the Object Browser it is PoyntProductCatalogWithProductListenerStub. However the Proxy is correctly nested underneath that. Will renaming the files IPoyntProductCatalogWithProductListener.Stub work? @ClintStLaurent

    Friday, December 1, 2017 9:59 PM
  • User180523 posted

    Will renaming the files IPoyntProductCatalogWithProductListener.Stub work? I"m no huge expert on android libraries. Every time I have to import them to a binding lib its a learning experiences. I couldn't just say 'yes' or 'no' to your questions. In the end its always be a case of working with them, and fixing using line by line and gaining a bit more of a 'feel' to doing it each time.

    Monday, December 4, 2017 1:14 PM
  • User381461 posted

    @DanielBoyer Seems like this is common issue for Java Binding Library generator ... (

    Have you fixed this issue ? I have the similar issue https://forums.xamarin.com/discussion/184666/xamarin-java-binding-library-multiple-already-defined-errors#latest and cannot figure out how to fix this ...

    Saturday, September 5, 2020 9:49 AM