3

我想看看新的 Awareness API,它是相当新的。我正在使用播放服务 9.0.2。该文档有这个例子

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

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

4

5 回答 5

6

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

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

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

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

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

于 2016-06-29T19:46:02.683 回答
0

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

设置 Google Play 服务

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

资源

于 2016-06-29T19:45:11.390 回答
0

设置 Google Play 服务

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

这显然与您从此处获取代码示例的页面相同

于 2016-06-29T19:46:44.767 回答
0

大多数情况下,您的应用程序中的方法引用数量超过 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/

于 2016-07-01T00:11:56.337 回答
0

启动 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'
于 2017-05-17T12:21:47.420 回答