Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 4992 [details]
Visual Studio Project File
I am trying to bind to the GA for Mobile v3 library located here:
Here is an error I am seeing on build:
Error 28 The type 'Com.Google.Tagmanager.Protobuf.AbstractMutableMessageLite' already contains a definition for 'cb_getDefaultInstanceForType'
When I search through the generated source folder for the term, "cb_getDefaultInstanceForType" I see a dozen different class files that each contain roughly the following:
static Delegate cb_getDefaultInstanceForType;
#pragma warning disable 0169
static Delegate GetGetDefaultInstanceForTypeHandler ()
if (cb_getDefaultInstanceForType == null)
cb_getDefaultInstanceForType = JNINativeWrapper.CreateDelegate ((Func<IntPtr, IntPtr, IntPtr>) n_GetDefaultInstanceForType);
Every time there is a method that returns this delegate, it re-defines the delegate above the method. I realize that there is a way to remove certain things via the Metadata.xml file, but I am unclear how I would go about doing it for this circumstance.
I have attached my project where these errors can be reproduced in Visual Studio. Any help in the right direction would be greatly appreciated. Thanks!
If I remember correctly that is caused by Java generics erasure (we have limitation on Java generics support) and derivation with erased type parameter.
Instead of inspecting and resolving the exact issue that should be resolved in Metadata.xml (by the way it should be done against Java API, so specifying things like "delegate" never works), I created another Metadata.xml which is based on:
- the existing binding sample https://github.com/xamarin/monodroid-samples/AnalyticsV2
- the idea that only documented API should be considered for binding, which is only about com.google.analytics.tracking.android (according to SDK javadoc)
<remove-node path="/api/package[@name!='com.google.analytics.tracking.android']" />
<attr path="/api/package[@name='com.google.analytics.tracking.android']" name="managedName">Xamarin.GoogleAnalyticsV3.Tracking</attr>
<!-- the Java class is derived from nonpublic type, which is not allowed in C# -->
<attr path="/api/package[@name='com.google.analytics.tracking.android']/class[@name='GoogleAnalytics']" name="extends">java.lang.Object</attr>
<!-- Java overrides protected method as public, which is not allowed in C# -->
<attr path="/api/package[@name='com.google.analytics.tracking.android']/class[@name='CampaignTrackingService']/method[@name='onHandleIntent']" name="visibility">protected</attr>
<!-- This special case binding change is required for Xamarin.Android internal -->
<attr path="/api/package[@name='com.google.analytics.tracking.android']/class[@name='CampaignTrackingService']" name="extends">mono.android.app.IntentService</attr>
I could build the binding with this Metadata.xml.
Maybe I should push this as AnalyticsV3 sample in the repository above.
Thanks Atsushi! I agree that this could be valuable for those wanting to use Google Analytics v3 and might be wise to put it in the repo.