Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)返回null_Android_Google Plus_Google Signin - Fatal编程技术网

Android Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)返回null

Android Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)返回null,android,google-plus,google-signin,Android,Google Plus,Google Signin,我尝试了所有方法,但仍然无法解决此问题,Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)总是返回null 这是我的代码: mGoogleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this)

我尝试了所有方法,但仍然无法解决此问题,
Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)
总是返回null

这是我的代码:

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

这是getProfileInformation():: /** *获取用户信息名称、电子邮件、个人资料图片 */"

我的Android清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="learn.english.from.hinkhoj" >

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name=".activity.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activity.LoginFragment"
            android:label="@string/title_activity_login_fragment" >
        </activity>
    </application>

</manifest>

你的应用程序和谷歌控制台之间的SHA1是否相同? 检查此线程(1)尝试将以下简单代码添加到回调中:

@Override
public void onConnected(Bundle bundle) {
    Person me = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
    if (me != null) {
        Person.Name name = me.getName();
        String given = name.getGivenName();
        String family = name.getFamilyName();

        Log.d(TAG, "Given: " + given + ", Family: " + family);
    }
}
2) 将两个SHA1签名添加到-一个从真实密钥库提取,另一个用于
~/.android/debug.keystore
(在Mac和Linux上;在Windows上搜索类似路径):

3) 在以下位置启用“Google+API”和“Google Play Android开发者API”:

4) 在调试之前,请运行以下命令:

adb shell setprop log.tag.GooglePlusPlatform VERBOSE
adb logcat

5) 如果没有什么帮助-等待几个小时。昨天晚上,我遇到了一个应用程序问题(
Plus.PeopleApi.getCurrentPerson()
无论我怎么尝试,都返回null)。今天早上,谷歌的爪牙们已经把它修好了。

如果你有任何错误,发布日志。发布您的代码以便我们提供帮助我没有收到任何错误日志仅此plus.peopleapi.getcurrentperson返回Null是否已从开发人员控制台启用api是否已在清单中添加相关权限?发布你的应用程序是处于开发模式还是发布模式?你说的“从你真正的密钥库”是什么意思??我在执行keytool命令时得到了一个SHA1密钥,但我不知道我的密钥库是什么。
@Override
public void onConnected(Bundle bundle) {
    Person me = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
    if (me != null) {
        Person.Name name = me.getName();
        String given = name.getGivenName();
        String family = name.getFamilyName();

        Log.d(TAG, "Given: " + given + ", Family: " + family);
    }
}
keytool -exportcert -keystore ~/.android/debug.keystore -list -v
adb shell setprop log.tag.GooglePlusPlatform VERBOSE
adb logcat