2

I am trying to build an android app that can connect to a smartwatch, I've followed the official docs on this page to use the DataLayer to connect both devices, right now I am struggling with finding the connected nodes so I can get the nodeId of the wearable and use it to connect to the watch.

This is what I did so far:

private Collection<String> getNodes() {
    HashSet<String> results = new HashSet<>();

    Task<List<Node>> nodeListTask =
            Wearable.getNodeClient(this).getConnectedNodes();

    try {
        List<Node> nodes = Tasks.await(nodeListTask);

        for (Node node : nodes) {
            results.add(node.getId());
        }

    } catch (ExecutionException exception) {
        Log.e(TAG, "Task failed: " + exception);

    } catch (InterruptedException exception) {
        Log.e(TAG, "Interrupt occurred: " + exception);
    }

    return results;
}

but I get this error when I launch the app:

com.google.android.gms.common.api.ApiException: 17: API: Wearable.API is not available on this device.

I also followed the sample provided by google and I still couldn't fix this issue, I searched here on StackOverflow and on the official docs and I would appreciate it if someone can guide me on how to fix this.

Mirou
  • 90
  • 1
  • 9

1 Answers1

1

I have a faced similar issue ! try installing the wearOS app and try again.

Divesh
  • 112
  • 1
  • 6
  • did this help you fix the error ? – Divesh Jan 05 '23 at 10:11
  • Sorry @Divesh I haven't gotten to it yet, I've been trying to use [gadgetbridge](https://github.com/ydon1111/Gadgetbridge) to connect to my smart watch. – Mirou Jan 09 '23 at 22:05
  • Is this [the app](https://play.google.com/store/apps/details?id=com.google.android.wearable.app) you mentioned? – Mirou Jan 09 '23 at 22:06
  • YES ! Install it and now you won't get the "API not available" error – Divesh Jan 17 '23 at 12:43
  • thanks for confirming, I am working on another project currently, I'll try that when I have time and let you know! – Mirou Jan 18 '23 at 21:44