Bug 29503 - LocationServices GoogleApiClientBuilder crash
Summary: LocationServices GoogleApiClientBuilder crash
Status: RESOLVED ANSWERED
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: N/A
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jon Dick
URL:
Depends on:
Blocks:
 
Reported: 2015-04-28 18:31 UTC by Dylan
Modified: 2015-05-05 19:13 UTC (History)
2 users (show)

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


Attachments
Repro working (45.23 KB, application/zip)
2015-04-30 13:54 UTC, Jon Dick
Details
Working solution (57.74 KB, application/zip)
2015-05-05 19:13 UTC, Jon Dick
Details


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:
RESOLVED ANSWERED

Description Dylan 2015-04-28 18:31:11 UTC
The following code crashes when the Build() method is called.            

var apiClient = new GoogleApiClientBuilder(Application.Context);
            apiClient.AddConnectionCallbacks(this);
            apiClient.AddOnConnectionFailedListener(this);
            apiClient.AddApi(LocationServices.Api);
            var client = apiClient.Build();


Compiled using API 21, xamarin.googleplayservices 22.0.0.2.

Any idea what could be causing this?


Crash log:
Details: 
   {
      Error: 
      {
         Data: {},
         ClassName: Java.Lang.NullPointerException,
         Message: "NullPointerException: Exception of type 'Java.Lang.NullPointerException' was thrown.",
         StackTrace: 
         [
            {
               LineNumber: 0,
               ClassName: System.Runtime.ExceptionServices.ExceptionDispatchInfo,
               MethodName: Throw()
            },
            {
               LineNumber: 178,
               ClassName: Android.Runtime.JNIEnv,
               FileName: /Users/builder/data/lanes/1353/86274adf/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs,
               MethodName: "CallObjectMethod(IntPtr jobject,
                IntPtr jmethod)"
            },
            {
               LineNumber: 0,
               ClassName: Android.Gms.Common.Apis.GoogleApiClientBuilder,
               MethodName: Build()
            },
            {
               LineNumber: 0,
               FileName: --- End of managed exception stack trace ---
            },
            {
               LineNumber: 0,
               FileName: "java.lang.NullPointerException: null reference"
            },
            {
               LineNumber: 0,
               FileName:    at com.google.android.gms.internal.jx.i(Unknown Source)
            },
            {
               LineNumber: 0,
               FileName:    at com.google.android.gms.internal.jm.registerConnectionCallbacks(Unknown Source)
            },
            {
               LineNumber: 0,
               FileName:    at com.google.android.gms.common.api.c.(Unknown Source)
            },
            {
               LineNumber: 0,
               FileName:    at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source)
            },
            {
               LineNumber: 0,
               FileName:    at mono.java.lang.RunnableImplementor.n_run(Native Method)
            },
            {
               LineNumber: 0,
               FileName: "mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)"
            },
            {
               LineNumber: 0,
               FileName: "android.os.Handler.handleCallback(Handler.java:615)"
            },
            {
               LineNumber: 0,
               FileName: "android.os.Handler.dispatchMessage(Handler.java:92)"
            },
            {
               LineNumber: 0,
               FileName: "android.os.Looper.loop(Looper.java:137)"
            },
            {
               LineNumber: 0,
               FileName: "android.app.ActivityThread.main(ActivityThread.java:4745)"
            },
            {
               LineNumber: 0,
               FileName:    at java.lang.reflect.Method.invokeNative(Native Method)
            },
            {
               LineNumber: 0,
               FileName: "java.lang.reflect.Method.invoke(Method.java:511)"
            },
            {
               LineNumber: 0,
               FileName: "com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)"
            },
            {
               LineNumber: 0,
               FileName: "com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)"
            },
            {
               LineNumber: 0,
               FileName:    at dalvik.system.NativeStart.main(Native Method)
            },
            {
               LineNumber: 0,
               FileName: 
            }
         ]
      }
Comment 1 Jon Dick 2015-04-30 09:24:21 UTC
Did you grant your application the ACCESS_COURSE_LOCATION and/or ACCESS_FINE_LOCATION permissions?

I can't replicate this failing on the 24.0.0.0-alpha1 release of the Google Play Services nuget.
Comment 2 Jon Dick 2015-04-30 09:30:22 UTC
Also working for me with 22.0.0.2 nuget package using Xamarin.Android stable (5.1).
Comment 3 Jon Dick 2015-04-30 13:54:37 UTC
Created attachment 10987 [details]
Repro working
Comment 4 Jon Dick 2015-05-05 19:12:45 UTC
Worked with Dylan over email with this and I think it's safe to close.

I have yet another attachment that illustrates everything working.

Looks like the class that implements some of the Google Play interfaces also needs to be a Java.Lang.Object.
Comment 5 Jon Dick 2015-05-05 19:13:13 UTC
Created attachment 11077 [details]
Working solution