【问题标题】:Google Plus Android API: "The method setActions(String[]) is undefined for the type PlusClient.Builder"Google Plus Android API:“PlusClient.Builder 类型的方法 setActions(String[]) 未定义”
【发布时间】:2013-11-11 20:50:08
【问题描述】:

我正在尝试使示例 Android Google+ 应用正常工作...(此处由 Google 提供的示例应用:https://developers.google.com/+/quickstart/android

“setAction”方法出现编译错误:

mPlusClient = new PlusClient.Builder(this, this, this)
                .setActions(MomentUtil.ACTIONS) // Compiling error here !
                .build();

我得到“方法 setActions(String[]) 未为 PlusClient.Builder 类型定义”

有人知道我为什么会收到这个错误???

谢谢!!

【问题讨论】:

  • 您安装了哪个版本的 Google Play 服务?
  • 好的,确实是版本问题。现在,我有: 1)在我的手机上:服务 Google Play 版本 3.2.66 2)在我的 Mac 上:SDK rev。 13 现在,我可以启动 Google Plus SDK 示例应用程序,但是当我想登录此示例应用程序时,我收到消息“除非您更新 Google Play 服务,否则此应用程序将无法运行”......关于原因的任何想法这个问题?

标签: android eclipse api google-plus google-play-services


【解决方案1】:

1) 转到 SDK Manager 并转到 extras 并选择 google play services 并安装最新更新。

2) 然后浏览您的 sdk 文件夹,如 sdk/extras/google/.. 您将找到库项目。将该项目导入工作区并将其作为库添加到您的项目中。

3) 然后清理构建并运行。

【讨论】:

    【解决方案2】:

    "该类型的方法 setActions(String[]) 未定义 PlusClient.Builder"

    表示您将字符串数组传递给 setActions 方法,但 API Doc setActions (String... actions) 方法将 String 作为操作参数而不是字符串数组

    因为setActions 方法采用可变参数(Varargs),因此您可以在 setActions 方法中传递多个字符串,而无需将数组用作:

    mPlusClient = new PlusClient.Builder(this, this, this)
                    .setActions(MomentUtil.ACTIONS[0],
                                MomentUtil.ACTIONS[1],....) 
                    .build();
    

    【讨论】:

    • 您的意思是我必须更正错误的 Google 示例应用程序的代码吗?代码中有很多地方出现了这个错误,而且在所有情况下都不容易纠正……感谢您的帮助。
    • 好的,版本有问题。现在,我有: 1)在我的手机上:服务 Google Play 版本 3.2.66 2)在我的 Mac 上:SDK rev。 13. 现在,我可以启动 Google Plus SDK 示例应用程序,但是当我想登录此示例应用程序时,我收到消息“除非您更新 Google Play 服务,否则此应用程序将无法运行”......关于原因的任何想法这个问题?
    【解决方案3】:

    他们将方法名称从 setActivities 更改为 setActions。

    http://developer.android.com/reference/com/google/android/gms/plus/PlusClient.Builder.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 2023-01-10
      • 1970-01-01
      • 2020-11-17
      • 1970-01-01
      • 2015-04-23
      相关资源
      最近更新 更多