CapabilityApi does not return any Nodes

独自空忆成欢 提交于 2019-12-04 17:26:20

Short answer:

Use the same debug certificate for both the handheld and wearable app, otherwise the CapabilityApi won't work.


Long Answer:

The error turned out to be pretty simple! Fixing it just involves editing the signingConfig in the build.gradle.

I was using a common debug certificate for signing the debug builds of my handheld app:

signingConfigs {
    debug {
        storeFile file("debug.jks")
        storePassword ...
        keyAlias ...
        keyPassword ...
    }
}

buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        ...
    }
}

But my wearable app was not using that same debug certificate, it was apparently using the default debug certificate supplied by my IDE. It seems that when the handheld and wearable app are not using the same certificate - even when it is just a debug build - then the capabilities of a device cannot be found by the other one. Which makes a lot of sense actually, what makes this whole thing confusing is that everything else seems to work just fine and as such pinpointing a problem like this is difficult.

In my case I removed the common debug singing config from the build.gradle of my handheld app and the CapabilityApi started working immediately. I think setting the same debug signingConfig for the wearable and handheld app would also fix the problem but I didn't test that for now.

Check if:

  • ApplicationId in build.gradle for both modules is the same
  • The package name for both modules is the same
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!