【问题标题】:Which dependency is required for Awareness API?Awareness API 需要哪个依赖项?
【发布时间】:2016-06-29 19:40:40
【问题描述】:

我想看看全新的 Awareness API。我正在使用 Play 服务 9.0.2。文档有this example:

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

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

【问题讨论】:

标签: android google-awareness


【解决方案1】:

我发现:我需要升级到 PlayServices 9.2.0 并且依赖项隐藏在 play-services-contextmanager 中。只需添加这些依赖项即可:

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

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

如果你想知道最新的依赖,你可以使用我的网络工具DependencyLookup

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

【讨论】:

    【解决方案2】:

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

    设置 Google Play 服务

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

    Source

    【讨论】:

    • 我添加了播放服务,但仍然没有找到该类。
    • 意识课?
    • 是的,我同时发现了依赖关系。
    【解决方案3】:

    设置 Google Play 服务

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

    这显然与您从here 获得代码示例的页面相同

    【讨论】:

    • 是的,它是 PlayServices 的一部分,但我正在寻找确切的依赖关系。
    【解决方案4】:

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

    【讨论】:

      【解决方案5】:

      启动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'
      

      【讨论】:

        猜你喜欢
        • 2014-01-24
        • 2020-04-21
        • 2016-09-28
        • 2018-09-20
        • 2022-08-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-17
        相关资源
        最近更新 更多