Android Wear CapabilityApi cannot find handheld ca

2020-07-15 07:32发布

问题:

I'm attempting to use MessageAPI to communicate back and forth between my handheld app and wearable app. I can't get the communication to work. I can confirm the devices are connected, but when my code executes, it acts like neither app has registered the Capability I am requesting.

  • notifications are successfully sent from handheld to the wear device
  • Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await() returns a list showing the handheld or wearable is indeed connected
  • Wearable.CapabilityApi.getAllCapabilities(mGoogleApiClient, CapabilityApi.FILTER_ALL).await() returns an empty list :-(
  • values/wear.xml has been set for both apps
  • both apps have the same applicationID set in gradle
  • both successfully connect to the GoogleApiClient
  • both register a listener with Wearable.MessageApi.addListener()

What other possible points of failure are there that I should check? My sample apps work great, and I integrated it into an existing simple project successfully, but when I add the same code to my major project, it doesn't work. I've combed through but can't find any code that could interfere with what I'm doing.

回答1:

Turned out that a line from the build.gradle file was causing the trouble.

debug { signingConfig null }

Removing this line fixed restored the connection between the Wear and the Handheld apps.