question

6666666 avatar image
0 Votes"
6666666 asked AndrsLeandro-5762 commented

Duplicate generate code in xamarin.android binding

I want to add a jar file to the xamarin binding.

here is the code
#region "Event implementation for IOnIndoorBuildingActiveListener"

  public event EventHandler<IndoorBuildingActiveEventArgs> IndoorBuildingActive {
  add {
  global::Java.Interop.EventHelper.AddEventHandler<IOnIndoorBuildingActiveListener, IOnIndoorBuildingActiveListenerImplementor>(
  ref weak_implementor_AddOnIndoorBuildingActiveListener,
  __CreateIOnIndoorBuildingActiveListenerImplementor,
  AddOnIndoorBuildingActiveListener,
  __h => __h.Handler += value);
  }
  remove {
  global::Java.Interop.EventHelper.RemoveEventHandler<IOnIndoorBuildingActiveListener, IOnIndoorBuildingActiveListenerImplementor>(
  ref weak_implementor_AddOnIndoorBuildingActiveListener,
                 IOnIndoorBuildingActiveListenerImplementor.__IsEmpty,
  __v => RemoveOnIndoorBuildingActiveListener (__v),
  __h => __h.Handler -= value);
  }
  }
    
  public event EventHandler<IndoorBuildingActiveEventArgs> IndoorBuildingActive {
  add {
  global::Java.Interop.EventHelper.AddEventHandler<IOnIndoorBuildingActiveListener, IOnIndoorBuildingActiveListenerImplementor>(
  ref weak_implementor_SetOnIndoorBuildingActiveListener,
  __CreateIOnIndoorBuildingActiveListenerImplementor,
  SetOnIndoorBuildingActiveListener,
  __h => __h.Handler += value);
  }
  remove {
  global::Java.Interop.EventHelper.RemoveEventHandler<IOnIndoorBuildingActiveListener, IOnIndoorBuildingActiveListenerImplementor>(
  ref weak_implementor_SetOnIndoorBuildingActiveListener,
                 IOnIndoorBuildingActiveListenerImplementor.__IsEmpty,
  __v => SetOnIndoorBuildingActiveListener (null),
  __h => __h.Handler -= value);
  }
  }
    
  WeakReference weak_implementor_AddOnIndoorBuildingActiveListener;

you can see there is two EventHandler with the same name but in the java code there is one:

 public static interface OnIndoorBuildingActiveListener {
     void OnIndoorBuilding(IndoorBuildingInfo param1IndoorBuildingInfo);
   }

and there is no the path of it how to fix it?

dotnet-xamarinforms
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

could you please provide your metadata file?

0 Votes 0 ·
6666666 avatar image 6666666 NicoleLu-9366 ·

I have write nothing in metadata file.

Now I find out the reason. Maybe there are two interface with the same name I should change the event Name right?

the

 public static interface OnIndoorBuildingActiveListener {
      void OnIndoorBuilding(IndoorBuildingInfo param1IndoorBuildingInfo);
    }

interface 's name can not be changed now.

since the path is wrong I set it but not work I do not know how to set the path

the "/api/package[@name='com.xxx.xxx']/class[@name='C']/interface[@name='OnIndoorBuildingActiveListener'] not right.

0 Votes 0 ·

Either a class or an interface can be specified in one path, and you can always refer to the Xamarin.Android binding metadata file to check for the gramma:
https://github.com/xamarin/xamarin-android/blob/main/src/Mono.Android/metadata

0 Votes 0 ·
Show more comments

there is two EventHandler with the same name

Sorry for the late reply. The two EventHandlers are not the same, you can see one is AddOnIndoorBuildingActiveListener and the other is SetOnIndoorBuildingActiveListener.

0 Votes 0 ·

Hi. I'm also having this problem; it seems that. when a Java class has two attributes which implement the same interface, the binding library generates duplicated event names to manage the two attributes. Is there a way to change such methdod names, given that Metadata.xml refers to the Java library, and these events don't exist there?

0 Votes 0 ·

0 Answers