无法登录Google帐户登录失败

时间:2019-07-26 06:31:45

标签: java api android-studio google-signin

我已经在我的应用中创建了Google和Facebook登录名,但是我无法通过显示为SignIn failed的Google帐户登录。

我已经看到该代码不会显示错误,但该应用程序也不会崩溃,但是我无法通过Google登录。我尝试了许多不同的google帐户,但每次显示“ SIGNIN FAILED”。

    private void signIn() {
    if (checkPermission()) {
        if (UtilityMethods.isInternetAvailable(mContext)) {
            new GetQuestionOfTheDay(mContext).execute();
            new GetQuickTen(mContext).execute();
            loginType = "Google";
            Intent signInIntent = mGoogleSignInClient.getSignInIntent();
            startActivityForResult(signInIntent, RC_SIGN_IN);
        } else {
            UtilityMethods
                    .showAlert(mContext, "No Internet Connection", 
   "Please enable internet connection to login.",
                               "Ok");
        }
    } else {
        requestPermission(ChoiceActivity.this);
    }
 }

 private void fbSignIn() {
    if (checkPermission()) {
        if (UtilityMethods.isInternetAvailable(mContext)) {
            new GetQuestionOfTheDay(mContext).execute();
            new GetQuickTen(mContext).execute();
            loginType = "Facebook";
            loginButton.performClick();
        } else {
            UtilityMethods
                    .showAlert(mContext, "No Internet Connection", 
 "Please enable internet connection to login.",
                               "Ok");
        }
    } else {
        requestPermission(ChoiceActivity.this);
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent 
   data) {
    callbackManager.onActivityResult(requestCode, resultCode, data);
    super.onActivityResult(requestCode, resultCode, data);

    // Result returned from launching the Intent from 
 GoogleSignInClient.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        // The Task returned from this call is always completed, no need 
to attach a listener.
        Task<GoogleSignInAccount> task = 
   GoogleSignIn.getSignedInAccountFromIntent(data);
        handleSignInResult(task);
    }
 }

  private void handleSignInResult(Task<GoogleSignInAccount> 
   completedTask) {
    try {
        GoogleSignInAccount account = 
     completedTask.getResult(ApiException.class);
        displayName = account.getDisplayName();
        socialMailId = account.getEmail();
        new Registration().execute();
    } catch (ApiException e) {
        // The ApiException status code indicates the detailed failure 
    reason.
        // Please refer to the GoogleSignInStatusCodes class reference 
   for more information.
        AppUtil.log(TAG, "signInResult:failed code=" + e.getStatusCode(), 
   e);
        Toast.makeText(mContext, "SignIn Failed ...", 
     Toast.LENGTH_SHORT).show();
        databaseHandler.flushQuickTenData();
        // updateUI(null);
    }
 }

 @Override
 public void onRequestPermissionsResult(int requestCode, @NonNull 
 String[] permissions,
                                       @NonNull int[] grantResults) {
    switch (requestCode) {
        case MY_REQUEST: {
            if (grantResults.length > 0) {
                boolean isReadExternalStoragePermission = grantResults[0] 
  == PackageManager.PERMISSION_GRANTED;
                boolean isWriteExternalStoragePermission = 
  grantResults[1] == PackageManager.PERMISSION_GRANTED;
                if (isReadExternalStoragePermission && 
 isWriteExternalStoragePermission) {
                    Toast.makeText(ChoiceActivity.this, "All Permission 
    Granted", Toast.LENGTH_SHORT).show();
                    isAccess = true;
                } else {
                    isAccess = false;
                    int i = 0;
                    StringBuilder stringBuilder = new StringBuilder();
                    if (isReadExternalStoragePermission && 
    isWriteExternalStoragePermission) {
                        if (i == 1) {
                            stringBuilder.append(", Storage");
                        } else {
                            stringBuilder.append("Storage");
                        }
                    }
                    Toast.makeText(ChoiceActivity.this, 
    stringBuilder.toString() + " Permission Denied",
                                   Toast.LENGTH_SHORT).show();
                }
            }
            break;
        }
     }
 }

我尝试调试应用程序,因此当我按Google中的“帐户”按钮时,它会在我的调试器中显示此错误。

 E/ChoiceActivity: signInResult:failed code=10
 com.google.android.gms.common.api.ApiException: 10:       at 
 com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus
 (UnknownSource) at 
 com.google.android.gms.auth.api.signin.GoogleSignIn.
 getSignedInAccountFromIntent(Unknown Source)
    at com.taxsmart.activity.ChoiceActivity.onActivityResult
    (ChoiceActivity.java:284)
    at android.app.Activity.dispatchActivityResult(Activity.java:6461)
    at android.app.ActivityThread.deliverResults
    (ActivityThread.java:3960)
    at android.app.ActivityThread.handleSendResult
    (ActivityThread.java:4007)
    at android.app.ActivityThread.-wrap16(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage
   (ActivityThread.java:1551)
    at android.os.Handler.dispatchMessage(Handler.java:111)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5763)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
    (ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)"

0 个答案:

没有答案