简体   繁体   English

Awareness API需要哪种依赖关系?

[英]Which dependency is required for Awareness API?

I want to check out the new Awareness API which is quite new. 我想查看新的Awareness API,这是一个非常新的。 I'm using Play Services 9.0.2. 我正在使用Play Services 9.0.2。 The documentation has this example : 该文档有这个例子

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

However, there is no hint which dependency needs to been added. 但是,没有提示需要添加哪些依赖项。 Any idea? 任何的想法?

I found it out: I need to upgrade to PlayServices 9.2.0 and the dependency is hidden in play-services-contextmanager . 我发现了:我需要升级到PlayServices 9.2.0并且依赖项隐藏在play-services-contextmanager Just add those dependencies and here we go: 只需添加这些依赖项,我们就在这里:

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

Please use the latest play services library, at the time I updated this answer it was 10.2.4 请使用最新的播放服务库,当时我更新了这个答案,它是10.2.4

If you want to know the latest Dependency you can use my web tool called DependencyLookup . 如果您想了解最新的Dependency,可以使用我的名为DependencyLookup的 Web工具。

Keep in mind that this library was added in the Play Services Repository v31. 请记住,此库已添加到Play Services Repository v31中。 Make sure that you have at least that version installed in the SDK manager. 确保您在SDK管理器中至少安装了该版本。

You need to add the library of Google Play services to your project. 您需要将Google Play服务库添加到您的项目中。

Set up Google Play services 设置Google Play服务

To access the Awareness API, your app's development project must include Google Play services. 要访问Awareness API,您应用的开发项目必须包含Google Play服务。 Download and install the Google Play services component via the SDK Manager and add the library to your project. 通过SDK Manager下载并安装Google Play服务组件,并将库添加到您的项目中。 For details, see the Android guide to setting up Google Play services. 有关详细信息,请参阅Android指南以设置Google Play服务。

Source 资源

Set up Google Play services 设置Google Play服务

To access the Awareness API, your app's development project must include Google Play services. 要访问Awareness API,您应用的开发项目必须包含Google Play服务。 Download and install the Google Play services component via the SDK Manager and add the library to your project. 通过SDK Manager下载并安装Google Play服务组件,并将库添加到您的项目中。 For details, see the Android guide to setting up Google Play services . 有关详细信息,请参阅Android指南以设置Google Play服务

which is apparently on the same page you got your code sample from here 这显然是在同一页面上,您从这里获得了代码示例

Most of the times the number of method references in your app exceeds the 65K limit, your app may fail to compile. 大多数情况下,应用程序中方法引用的数量超过65K限制,您的应用程序可能无法编译。 So in order to mitigate this problem when compiling your app ,specify only the specific Google Play services APIs your app uses, instead of all of them. 因此,为了在编译应用时缓解此问题,请仅指定应用使用的特定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'

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

Starting PlayServices v9.6.0, contextmanager has been changed to awareness 启动PlayServices v9.6.0后, contextmanager已更改为awareness

So, the previous answers won't be working. 所以,之前的答案将不起作用。

The correct dependencies, as of v10.2.4 are 从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