3

I've tried to use Nearby Connections, but I keep getting the dialog "Google Play Services" has crashed. The logcat shows a stack trace like this:

04-08 20:01:32.309 8904-11589/? E/AndroidRuntime: FATAL EXCEPTION: highpool[3]
                                                  Process: com.google.android.gms.nearby.connection, PID: 8904
                                                  java.lang.NullPointerException: Attempt to read from field 'java.lang.Object pu.a' on a null object reference
                                                      at vsb.e(:com.google.android.gms:244)
                                                      at vsr.run(:com.google.android.gms:344)
                                                      at lmq.run(:com.google.android.gms:450)
                                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                      at lra.run(:com.google.android.gms:17)
                                                      at java.lang.Thread.run(Thread.java:818)

Where the specific random letters can change.

After further investigation, it seems to occur when a device is attempting to discover advertising devices and the timeout it specifies ends.

I went to report the issue and found someone already had:

https://code.google.com/p/android/issues/detail?can=1&start=0&num=100&q=nearby%20connections%20nullpointerexception&colspec=ID%20Status%20Priority%20Owner%20Summary%20Stars%20Reporter%20Opened&groupby=&sort=&id=316748

Very few apps seem to use Nearby Connections; I know of none. The official documentation isn't great. Heck, Nearby.Connections.startAdvertising() still wants a AppMetadata parameter, which Google has deprecated.

The official code example, https://github.com/googlesamples/android-nearby , is obsolete and non-functional.

So my question is: how can I work around these issues? Is there a modern, working example of Nearby Connections anywhere? Or is the Nearby Connections API itself simply unused and completely broken?

Chad Schultz
  • 7,770
  • 6
  • 57
  • 96
  • "a null object reference" says that you should find the problem in your code, it is possible you are trying to use a class that is not created. Edit your post and add your code – Mahmoud_Mehri Apr 08 '17 at 21:09
  • 1
    I have already checked every parameter I pass to the Nearby API to ensure none are null. The NullPointerException is thrown from Google's code, not mine. As I mentioned, and the linked bug report mentions, the official sample from Google no longer works and itself throws the error. – Chad Schultz Apr 09 '17 at 10:37
  • @ChadSchultz May you offer a bounty to solve the question? – trinity420 Apr 14 '17 at 10:46
  • Nah. I'm pretty sure it's just completely broken, so there's no point throwing hard-earned reputation away for no benefit. – Chad Schultz Apr 14 '17 at 17:43

1 Answers1

1

We significantly revamped Nearby Connections in the 11 release of Google Play Services. There's a bunch of new functionally, rewritten docs and new samples on the dev site.

Brian Duff
  • 406
  • 3
  • 12