xamarinxamarin.androidtwilioxamarin-bindingtwilio-programmable-voice

Error CS0115: no suitable method found to override in a Xamarin bindings library project


I created a bindings library project to be able to run an Android .aar file. One of the several errors i got was:

Error  CS0115  'Call.OnWarning(IDictionary)': no suitable method found to override TwilioBindings  C:\...\TwilioBindings\obj\Debug\generated\src\Com.Twilio.Voice.Call.cs;

And to solve it i verified api.xml and saw that the method onWarning had a parameter with the type java.util.HashMap:

<method abstract="false" deprecated="not deprecated" final="false" name="onWarning" native="false" return="void" static="false" synchronized="false" visibility="public">
    <parameter name="p0" type="java.util.HashMap">
    </parameter>
</method>

The class Call is extending InternalCall which implements RTCMonitorCommand.Listener and after i checked the api.xml file i notice that the method onWarning had the follow definition:

InternalCall:

<method abstract="false" deprecated="not deprecated" final="false" name="onWarning" native="false" return="void" static="false" synchronized="false" visibility="public">
    <parameter name="warningDetails" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
    </parameter>
</method>

RTCMonitorCommand.Listener:

<method abstract="true" deprecated="not deprecated" final="false" name="onWarning" native="false" return="void" static="false" synchronized="false" visibility="public">
    <parameter name="p0" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
    </parameter>
</method>

So i came to the conclusion that only the class Call had a diferent parameter type.

Therefore i wrote the follow line in Metadata.xml to change the parameter type of the method onWarning in class Call:

<attr path="/api/package[@name='com.twilio.voice']/class[@name='Call']/method[@name='onWarning' and count(parameter)=1 and parameter[1][@type='java.util.HashMap']]/parameter[1]" name="type">java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;</attr>

The error went away but i'm having some problems using this bindings project and this is the line in Metadata.xml that i'm not shure that is right.

Does anyone know if my approach was correct ?

Any help whould be apreciated,

Thank you.


Solution

  • I was having problems when calling a method from this binding library and i thought that was caused by some binding error but then, after searching in the logs i came to the conclusion that the problem was that the library wasn't being able to find a dependency. The dependency project was being referenced by the binding project but somehow the reference wasn't working. So i changed the reference and instead of referencing the package i referenced the package dll and now it functions properly.