question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Empty array of services is returned

See original GitHub issue

Expected Behavior

After calling bleManager.discoverAllServicesAndCharacteristicsForDevice(), calling .services() on the returned bleDevice should return a non-empty list of services.

Current Behavior

Calling .services() returns an empty array. This might be a pairing issue, since if I pair with the device via Android’s bluetooth menu, it seems to connect without issue and properly returns a non-empty list of services. Restarting the phone also seems to “fix” the issue for me. I assume this issue is related to https://github.com/Polidea/react-native-ble-plx/issues/488 and the “known bug”. Calling connectToDevice() seems to work fine, and the resulting device has the correct name/id.

Steps to Reproduce

  1. Put device in pairing mode
  2. Connect to device using bleManager.connectToDevice().
  3. Call discoverAllServicesAndCharacteristicsForDevice() with the device or using bleManager.
  4. Attempt to get services using .services() on the device.
  5. An empty services array is returned.

Context

  • Library version: 2.0.1
  • Platform and version: Android 10 (SDK 29)
  • Phone: Samsung Galaxy S20

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:20 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
TwoTenPvPcommented, Nov 21, 2020

Could you share what configuration problem it was? It could be helpful for anyone else that would stumble upon this issue.

I actually still don’t know. I’m running a Bluez server. And whenever a connection request comes in it gets disconnected by the server. So a server side issue, unrelated to this library.

1reaction
TwoTenPvPcommented, Nov 21, 2020

I think I have a related issue.

I am trying to find my device by serviceUUID and that does not work.

uuids = ["UUID_GOES_HERE"]
bluetoothManager.startDeviceScan(uuids, null, (error, device) => { }

The above code never finds anything.

If I remove the uuids argument to make it find everything, then manually filter on the MAC address to get the reported device object. Getting it’s .serviceUUIDs also returns null.

My .name field is also empty on Discovery.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Android] Empty array of services is returned #766 - GitHub
Calling .services() returns an empty array. This might be a pairing issue, since if I pair with the device via Android's bluetooth menu, ......
Read more >
How to handle empty array return in API response in retrofit 2 ...
can anyone help me in this ? This is a 3rd party API which I am not able to modify response from server...
Read more >
Return an empty array or collection instead of a null
Returning a null value rather than a zero-length array or collection may lead to denial-of-service vulnerabilities when the client code fails to handle...
Read more >
ArrayAdapter | Android Developers
You can use this adapter to provide views for an AdapterView , Returns a view for each object in a collection of data...
Read more >
Empty arrays and collections should be returned instead of null
Returning null instead of an actual array, collection or map forces callers of the method to explicitly test for nullity, making them more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found