Bug 27081 - Java.Lang.NoSuchMethod in GoogleApiClientBuilder.AddApi
Summary: Java.Lang.NoSuchMethod in GoogleApiClientBuilder.AddApi
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.20.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2015-02-16 00:24 UTC by Paul
Modified: 2015-02-18 20:55 UTC (History)
5 users (show)

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

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:
Status:
VERIFIED FIXED

Description Paul 2015-02-16 00:24:27 UTC
VERY URGENT

Hello, getting this exception when creating a CastApi client with this code:

var apiClient = apiClientBuilder.AddApi(CastClass.Api, optionsBuilder.Build()).AddConnectionCallbacks(this).AddOnConnectionFailedListener(this).Build();


Exception: Java.Lang.NoSuchMethod


no method with name='addApi' signature='(Lcom/google/android/gms/common/api/Api;Ljava/lang/Object;)Lcom/google/android/gms/common/api/GoogleApiClient$Builder;' in class Lcom/google/android/gms/common/api/GoogleApiClient$Builder;

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <IL 0x00011, 0x00068>
at Android.Runtime.JNIEnv.GetMethodID (intptr,string,string) [0x00066] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:162
at Android.Gms.Common.Apis.GoogleApiClientBuilder.AddApi (Android.Gms.Common.Apis.Api,Android.Gms.Common.Apis.Api/IApiOptionsHasOptions) <IL 0x00023, 0x000db>
at Go.ChromecastHelper/<>c__DisplayClass5.<ConnectTo>b__4 () [0x0007f] in c:\Projects\Foxtel\presto-1.0-development\android\Presto\ChromecastHelper.cs:364
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.IRunnable.cs:71
at (wrapper dynamic-method) object.f769e6a2-87f2-49d0-bc6f-b1a8591eef88 (intptr,intptr) <IL 0x00011, 0x0003b>

  --- End of managed exception stack trace ---
java.lang.NoSuchMethodError: no method with name='addApi' signature='(Lcom/google/android/gms/common/api/Api;Ljava/lang/Object;)Lcom/google/android/gms/common/api/GoogleApiClient$Builder;' in class Lcom/google/android/gms/common/api/GoogleApiClient$Builder;
	at mono.java.lang.RunnableImplementor.n_run(Native Method)
	at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
	at android.app.Activity.runOnUiThread(Activity.java:4924)
	at go.MainActivity.n_onOptionsItemSelected(Native Method)
	at go.MainActivity.onOptionsItemSelected(MainActivity.java:66)
	at android.app.Activity.onMenuItemSelected(Activity.java:2708)
	at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:350)
	at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1094)
	at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
	at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
	at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
	at com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:645)
	at com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:210)
	at android.view.View.performClick(View.java:4637)
	at android.view.View$PerformClick.run(View.java:19422)
	at android.os.Handler.handleCallback(Handler.java:733)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:136)
	at android.app.ActivityThread.main(ActivityThread.java:5586)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
	at dalvik.system.NativeStart.main(Native Method)




Packages installed:
  <package id="Xamarin.Android.Support.v13" version="21.0.3.0" targetFramework="MonoAndroid44" />
  <package id="Xamarin.Android.Support.v4" version="21.0.3.0" targetFramework="MonoAndroid44" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="21.0.3.0" targetFramework="MonoAndroid44" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="21.0.3.0" targetFramework="MonoAndroid44" />
  <package id="Xamarin.GooglePlayServices" version="22.0.0.1" targetFramework="MonoAndroid44" />
  <package id="Xamarin.Insights" version="1.9.0.106" targetFramework="MonoAndroid44" />

Component:
Support v4





Xamarin info:

Xamarin Studio
Version 5.7.1 (build 17)
Installation UUID: a6a75a2e-663d-4f28-9bee-ec7d1889267d
Runtime:
	Microsoft .NET 4.0.30319.34209
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

Xamarin.Android
Version: 4.20.0 (Enterprise Edition)
Android SDK: C:\Users\pnovodon\AppData\Local\Android\android-sdk
	Supported Android versions:
		4.1 (API level 16)
		4.2 (API level 17)
		4.3 (API level 18)
		4.4 (API level 19)
		5.0 (API level 21)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

Build Information
Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:51:07-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

Operating System
Windows 6.1.7601.65536 (64-bit)
Comment 1 Paul 2015-02-16 21:14:54 UTC
Update: this is true for GooglePlayService version 22.0.0.1.
Reverting back to 22.0.0.0 fixes it.
Comment 2 Jon Dick 2015-02-18 08:27:30 UTC
Adding Dean to CC:

Looks like the wrong JNI signature is being generated for this method.

It previously was generated as:
[Register ("addApi", "(Lcom/google/android/gms/common/api/Api;Lcom/google/android/gms/common/api/Api$ApiOptions$HasOptions;)Lcom/google/android/gms/common/api/GoogleApiClient$Builder;", "")]
public GoogleApiClientBuilder AddApi (Api api, Api.IApiOptionsHasOptions options);

Now it's coming out as:
[Register ("addApi", "(Lcom/google/android/gms/common/api/Api;Ljava/lang/Object;)Lcom/google/android/gms/common/api/GoogleApiClient$Builder;", "")]
public GoogleApiClientBuilder AddApi (Api api, Api.IApiOptionsHasOptions options);

It's also worth noting that the following transform is being used on this method:
<attr path="/api/package[@name='com.google.android.gms.common.api']/class[@name='GoogleApiClient.Builder']/method[@name='addApi']/parameter[2]" name="managedType">Android.Gms.Common.Apis.Api.IApiOptionsHasOptions</attr>
Comment 3 Jon Dick 2015-02-18 09:11:53 UTC
This is an old bug rearing its head in jar2xml.  This has been fixed already in jar2xml, however it's not in a stable Xamarin.Android release.  The old jar2xml was inadvertently used to publish this update. 

A new Google Play Services v22.0.0.2 has been published to NuGet to address this issue.