Android GoogleSignIn API错误状态{statusCode=NETWORK_ERROR, resol



大家好!我有问题时,使用GoogleSignInApi。当我通过WIFI连接使用时,效果非常好。但是当我关闭WIFI,只使用移动数据时,我从Auth.GoogleSignInApi.getSignInIntent活动结果中获得GoogleSignInStatusCodes.NETWORK_ERROR

我使用Firebase UI进行身份验证,但我想它与模块无关,因为我直接从GoogleSignInApi获得网络错误。

这是我设置SignInOptions时的样子:

String mClientId = activity.getString(R.string.default_web_client_id);
GoogleSignInOptions googleSignInOptions;
GoogleSignInOptions.Builder builder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestIdToken(mClientId);               
for (String scopeString : idpConfig.getScopes()) {
    builder.requestScopes(new Scope(scopeString));
}
if (!TextUtils.isEmpty(email)) {
    builder.setAccountName(email);
}
googleSignInOptions = builder.build();
mGoogleApiClient = new GoogleApiClient.Builder(activity)
.enableAutoManage(activity, AUTO_MANAGE_ID, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
.build();

我是这样启动SignIn活动的:

Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
activity.startActivityForResult(signInIntent, RC_SIGN_IN);

这里是NETWORK_ERROR

 @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == RC_SIGN_IN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result != null) {
                if (result.isSuccess()) {
                    mIDPCallback.onSuccess(createIDPResponse(result.getSignInAccount()));
                } else {
                    onError(result);
                }
            } else {
                onError("No result found in intent");
            }
        }
    }

键等。我已经正确配置了一切,因为它在WIFI上工作得很好。

在权限端,我有所有请求的权限(并且正确处理Android 6.0)

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.READ_PROFILE" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

原来我已经禁用了Google Play设置的背景数据。这导致我在默认情况下即使在3G上也有适当的互联网连接,但GooglePlay服务被阻止访问互联网,这阻止了任何GooglePlay服务运行。

相关内容

  • 没有找到相关文章

最新更新