Android 套餐 com.google.android.gms.plus 不可用

Android package com.google.android.gms.plus not available

我正在尝试为我的应用程序集成 Google+ 登录。我按照 link https://developers.google.com/identity/sign-in/android/start-integrating 上的步骤操作。

我 运行 在下面的代码中调用 Plus.API 时遇到问题

// Build GoogleApiClient with access to basic profile
mGoogleApiClient = new GoogleApiClient.Builder(this)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .addApi(Plus.API)
        .addScope(new Scope(Scopes.PROFILE))
        .build();

无法识别 Plus。该包应该是 com.google.android.gms.plus,但它不存在。我试过更改 google 服务版本、重建、清理、删除 .iml 文件。我有一个新的 .json 配置文件。只是停滞不前。显然,我做错了什么,但不知道从哪里开始。

我们将不胜感激。

试试这个:

 GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Plus.API, Plus.PlusOptions.builder().build())
                .addScope(Plus.SCOPE_PLUS_LOGIN).build();

您在集成手册中是否遵循了这部分? https://developers.google.com/identity/sign-in/android/start-integrating


添加 Google 服务插件

Gradle 的 Google 服务插件解析来自 google-services.json 文件的配置信息。通过更新您的顶级 build.gradle 和应用级 build.gradle 文件,将插件添加到您的项目中,如下所示:

将依赖项添加到项目的顶级 build.gradle:

classpath 'com.google.gms:google-services:1.3.0-beta1'

将插件添加到您的应用级别 build.gradle:

apply plugin: 'com.google.gms.google-services'