Android Google Plus getCurrentPerson 返回 null

标签 android google-plus

当我调用 plusClient.getCurrentPerson() 时,我得到 NULL。

方法 onConnected(Bundle...) 在成功登录后调用:

@Override
public void onConnected(Bundle bundle)
{
   if (plusClient.getCurrentPerson() == null)
   {
      Log.e("DD", "Person is null !");
   }
}

我直接从 eclipse (Window->Preferences->Android->Build) 添加了 SHA1。我不知道我做错了什么!

来自 Eclipse ADT 的 SHA1 指纹 SHA1 fingerprint from Eclipse ADT

已安装应用程序的客户端 ID Client ID for installed applications

简单的 API 访问 Simple API access

最佳答案

就我而言,我忘记启用 google-plus 权限

希望它有用...如有任何疑问请告诉我

从头开始检查:

有时人物信息可能为空

检查:权限

要做的重要事情:

启用 Google 加 API

启用谷歌地图 Android API

如果你在本地测试然后在eclipse-->window-->preference option-->Android-->Build中添加sha1 key

您可以通过命令提示符生成 SHA1 key

keytool -list -v -keystore "C:\Users\User.android\debug.keystore"-alias androiddebugkey -storepass android -keypass android

如果您在 play-store 中发布应用,则需要在 google console 中更改 SHA1 key

因为在本地 SHA1 key 是不同的。完成signedApk后SHA1 key 不同

在生成签名的 apk 时 --> 在最后一个屏幕中 --> 你可以看到 SHA1 key

在谷歌控制台添加后你会得到API key

Manifest 文件中添加这个键值

enter image description here

关于Android Google Plus getCurrentPerson 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20554310/

相关文章:

java - Robolectric @config 指定 list 路径时,抛出空指针异常

c# - 如何在 Unity AndroidJavaClass 中访问枚举

ios - 如何在 ios 中使用 oauth 2 api 从 google plus 获取用户生日?

java - 我如何使用 Oauth2.0 从 Google Plus API 获取联系人

ios - GPPSignIn 生日属性缺失

iOS Google+ 获取好友数量

java - 错误 : Entities and Pojos must have a usable public constructor.

android - 与 Firebase 混淆变量范围

java - Android - ListView 在 setContentView() 之后消失?

iphone - Google plus API 不会在登录时返回到应用程序