繁体   English   中英

Awareness API需要哪种依赖关系?

[英]Which dependency is required for Awareness API?

我想查看新的Awareness API,这是一个非常新的。 我正在使用Play Services 9.0.2。 该文档有这个例子

GoogleApiClient client = new GoogleApiClient.Builder(context)
        .addApi(Awareness.API)
        .build();
client.connect();

但是,没有提示需要添加哪些依赖项。 任何的想法?

我发现了:我需要升级到PlayServices 9.2.0并且依赖项隐藏在play-services-contextmanager 只需添加这些依赖项,我们就在这里:

compile 'com.google.android.gms:play-services-awareness:10.2.4'

请使用最新的播放服务库,当时我更新了这个答案,它是10.2.4

如果您想了解最新的Dependency,可以使用我的名为DependencyLookup的 Web工具。

请记住,此库已添加到Play Services Repository v31中。 确保您在SDK管理器中至少安装了该版本。

您需要将Google Play服务库添加到您的项目中。

设置Google Play服务

要访问Awareness API,您应用的开发项目必须包含Google Play服务。 通过SDK Manager下载并安装Google Play服务组件,并将库添加到您的项目中。 有关详细信息,请参阅Android指南以设置Google Play服务。

资源

设置Google Play服务

要访问Awareness API,您应用的开发项目必须包含Google Play服务。 通过SDK Manager下载并安装Google Play服务组件,并将库添加到您的项目中。 有关详细信息,请参阅Android指南以设置Google Play服务

这显然是在同一页面上,您从这里获得了代码示例

大多数情况下,应用程序中方法引用的数量超过65K限制,您的应用程序可能无法编译。 因此,为了在编译应用时缓解此问题,请仅指定应用使用的特定Google Play服务API,而不是全部。

compile 'com.google.android.gms:play-services-basement:9.2.0'
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'

你会在这里找到完整的解决方案: http//xordroid.com/create-intelligent-apps-with-google-awareness-api/

启动PlayServices v9.6.0后, contextmanager已更改为awareness

所以,之前的答案将不起作用。

从v10.2.4开始,正确的依赖关系是

compile 'com.google.android.gms:play-services-basement:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM