Bug 14689 - Binding to Twilio JAR library fails with many 'already contains a definition for' errors.
Summary: Binding to Twilio JAR library fails with many 'already contains a definition ...
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.8.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Atsushi Eno
Depends on:
Reported: 2013-09-12 14:01 UTC by Jon Goldberger [MSFT]
Modified: 2014-04-28 13:50 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Test project (251.38 KB, application/zip)
2013-09-12 14:01 UTC, Jon Goldberger [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jon Goldberger [MSFT] 2013-09-12 14:01:13 UTC
Created attachment 4856 [details]
Test project

I have attempted to bind TwilioClient and keep getting

The type 'Com.Twilio.Client.Device' already contains a definition for 'StopListening'
The type 'Com.Twilio.Client.DisconnectedEventArgs' already contains a definition for 'p0'
The type 'Com.Twilio.Client.DisconnectedEventArgs' already contains a definition for 'P0'
The type 'Com.Twilio.Client.IConnectionListenerImplementor' already contains a definition for 'OnDisconnectedHandler'
The type 'Com.Twilio.Client.IDeviceListenerImplementor' already contains a definition for 'OnStopListeningHandler'
The type 'Com.Twilio.Client.Impl.Net.EventStream.IListenerImplementor' already contains a definition for 'OnDisconnectedHandler'
The type 'Com.Twilio.Client.StopListeningEventArgs' already contains a definition for 'p0'
The type 'Com.Twilio.Client.StopListeningEventArgs' already contains a definition for 'P0'

I decompiled the Jar to try and make sense of this. I don’t see a StopListening in the device class however I think the issue has to do with the following code which is in the DeviceImpl class as part of the constructor.

When I try to change the name of the attribute I get the following warnings

<attr path="/api/package[@name='com.twilio.client.impl']/class[@name='Device']/method[@name='DeviceListener.onStopListening']"/> matched no nodes
<attr path="/api/package[@name='com.twilio.client.impl']/class[@name='DeviceImpl']/method[@name='DeviceListener.onStopListening']"/> matched no nodes

this.dummyListener = new DeviceListener(fPresenceEnabled) {
public boolean receivePresenceEvents(Device inDevice) {
return this.val$fPresenceEnabled;

public void onStopListening(Device inDevice, int inErrorCode, String inErrorMessage)

public void onStopListening(Device inDevice)

public void onStartListening(Device inDevice)

public void onPresenceChanged(Device inDevice, PresenceEvent inPresenceEvent)
Comment 2 Jon Goldberger [MSFT] 2013-09-12 14:18:05 UTC
Version info:

Microsoft Visual Studio Professional 2012
Version 11.0.60610.01 Update 3
Microsoft .NET Framework
Version 4.5.50743

Installed Version: Professional

LightSwitch for Visual Studio 2012 04938-004-0034007-02138
Microsoft LightSwitch for Visual Studio 2012

Office Developer Tools 04938-004-0034007-02138
Microsoft Office Developer Tools

Team Explorer for Visual Studio 2012 04938-004-0034007-02138
Microsoft Team Explorer for Visual Studio 2012

Visual Basic 2012 04938-004-0034007-02138
Microsoft Visual Basic 2012

Visual C# 2012 04938-004-0034007-02138
Microsoft Visual C# 2012

Visual C++ 2012 04938-004-0034007-02138
Microsoft Visual C++ 2012

Visual F# 2012 04938-004-0034007-02138
Microsoft Visual F# 2012

Visual Studio 2012 Code Analysis Spell Checker 04938-004-0034007-02138
Microsoft® Visual Studio® 2012 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Visual Studio 2012 SharePoint Developer Tools 04938-004-0034007-02138
Microsoft Visual Studio 2012 SharePoint Developer Tools

Windows Phone SDK 8.0 - ENU 04938-004-0034007-02138
Windows Phone SDK 8.0 - ENU

AlignAssignments 1.0
Command for aligning assignments.

AnkhSVN - Subversion Support for Visual Studio 2.5.12040.334
AnkhSVN - Subversion Support for Visual Studio 2.5.12040.334
* Ankh.Package 2.5.12040.334
* Subversion 1.8.0 via SharpSvn 1.8000.2461.14986

SharpSvn is linked to: Apr 1.4.6, Apr-util 1.5.2, Cyrus Sasl 2.1.23, OpenSSL 1.0.1e 11 Feb 2013, serf 1.2.1, SQLite 3.7.17, Subversion 1.8.0-SharpSvn-1.8.0, ZLib 1.2.8
SharpSvn is optionally linked to: Berkeley DB 4.4.20, SharpPlink 1.8000.2461.14986

CustomDocWell 1.0
Provides configurable behavior for the document well in Visual Studio 2012.

GhostDoc 4.7.13226.0
GhostDoc automatically generates XML documentation comments.

Microsoft Advertising SDK for Windows Phone 6.2.923.0
Microsoft Advertising SDK for Windows Phone
Build 6.2.923.0

Microsoft XNA Game Studio 4.0
Microsoft XNA Game Studio 4.0
Build 4.0.40906.0

NuGet Package Manager 2.7.40808.167
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

OptionsPageImpl 1.0
Information about my package

PowerCommands for Visual Studio 2010 1.0
A set of power commands for Visual Studio 2010

PreEmptive Analytics Visualizer 1.0
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Quick Launch Tasks 1.0
Microsoft Quick LaunchTasks package adds accessibility and settings tasks to the Quick Launch tool.

SQL Server Data Tools 11.1.20905.0
Microsoft SQL Server Data Tools

Visual Studio 11 Editor Extension 1.0
Information about my package

VSCommands11 12.0
VSCommands 11

Web Developer Tools 1.3.40412.0
Microsoft Web Developer Tools contains the following components:
Page Inspector: Tool that offers an efficient way to decompose Web Applications and diagnose front-end issues.
Web Publishing: Extensions required for Web Publishing for both hosted servers as well as on premises.
Web Form Templates: Includes the default templates for Web Form Applications.
Editor Extensions: Includes HTML, CSS, and JS editor extensions that greatly enhance the development experience.

Windows Azure Tools 2.0
Windows Azure Tools for Microsoft Visual Studio 2012 - v2.0.60409.1601

Workflow Manager Tools 1.0 1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin.Android 4.8.01013 (b76e8ec4)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS 1.3.250 (49348a51)
Visual Studio extension to enable development for Xamarin.iOS

IdeaBlade Object Mapper
For more information about IdeaBlade, see the website at
Comment 3 Atsushi Eno 2013-09-17 11:29:21 UTC
Some of those errors are by design and you are supposed to make appropriate Metadata fixes. Your attempt to use eventName and argsType are about right, though type names and method names must exactly identify the target method.

Historically, we only supported "Listener" interfaces and relevant event generation only for those interfaces that have exactly one method. Where XxxListener interface has onYyy() method, a class that has setXxxListener() or setOnXxxListener() will have Yyy event. It was simple.

Now, we support interfaces that have multiple methods, some complicated things could happen. These interfaces reported here are one of those; they have method "overloads" i.e. more than one methods share the same name with different set of parameters. It is okay for methods, but definitely no-go for events. Thus, any of those methods need to be "renamed". And this cannot be automatically done as renaming by tools with no hint is not desirable, resulting in confusion.

Here is what I wrote to resolve this method overload issue:

  <attr path="/api/package[@name='com.twilio.client']/interface[@name='DeviceListener']/method[@name='onStopListening' and count(parameter)=3]" name="eventName">StopListening2</attr>
  <attr path="/api/package[@name='com.twilio.client']/interface[@name='DeviceListener']/method[@name='onStopListening' and count(parameter)=3]" name="argsType">StopListening2EventArgs</attr>
  <attr path="/api/package[@name='com.twilio.client']/interface[@name='ConnectionListener']/method[@name='onDisconnected' and count(parameter)=3]" name="eventName">Disconnected2</attr>
  <attr path="/api/package[@name='com.twilio.client']/interface[@name='ConnectionListener']/method[@name='onDisconnected' and count(parameter)=3]" name="argsType">Disconnected2EventArgs</attr>
  <attr path="/api/package[@name='com.twilio.client.impl.net']/interface[@name='EventStream.Listener']/method[@name='onDisconnected' and count(parameter)=2]" name="eventName">Disconnected2</attr>
  <attr path="/api/package[@name='com.twilio.client.impl.net']/interface[@name='EventStream.Listener']/method[@name='onDisconnected' and count(parameter)=2]" name="argsType">Disconnected2EventArgs</attr>

Apart from above, these metadata changes below are also needed, right now, but might become unnecessary depending on our generator design changes.

  <attr path="/api/package[@name='com.twilio.client']/interface[@name='DeviceListener']/method[@name='onStopListening' and count(parameter)=3]" name="managedName">OnStopListening2</attr>
  <attr path="/api/package[@name='com.twilio.client']/interface[@name='ConnectionListener']/method[@name='onDisconnected' and count(parameter)=3]" name="managedName">OnDisconnected2</attr>
  <attr path="/api/package[@name='com.twilio.client.impl.net']/interface[@name='EventStream.Listener']/method[@name='onDisconnected' and count(parameter)=2]" name="managedName">OnDisconnected2</attr>

(To me it can be said like some bug (picky people would say so), but I'm not sure if it really is, or it is really fixable, or it is worthy of messing generator code.)

Anyhow, with these metadata changes the event related issues go away and you will have to continue making further metadata changes for further issues.