Android 卡在“之后”;“与谷歌合作”;按钮被点击

Android 卡在“之后”;“与谷歌合作”;按钮被点击,android,firebase,google-signin,Android,Firebase,Google Signin,所以我一直在尝试使用谷歌登录,作为我应用程序的登录选项。当我单击sigin按钮时,应用程序会显示可用电子邮件的列表,但当我单击任何电子邮件时,应用程序都不会让我登录。我已经尝试了几乎所有的方法,包括向firebase添加SHA-1密钥,替换新的google-services.json文件。我已经重新检查了我的代码,但我一定是遗漏了什么。请帮我找出我的错误 编辑:我也在firebase中启用了Sigin和google 以下是我用于登录的代码: public class User_login ext

所以我一直在尝试使用谷歌登录,作为我应用程序的登录选项。当我单击sigin按钮时,应用程序会显示可用电子邮件的列表,但当我单击任何电子邮件时,应用程序都不会让我登录。我已经尝试了几乎所有的方法,包括向firebase添加SHA-1密钥,替换新的google-services.json文件。我已经重新检查了我的代码,但我一定是遗漏了什么。请帮我找出我的错误

编辑:我也在firebase中启用了Sigin和google

以下是我用于登录的代码:

public class User_login extends AppCompatActivity {


    private static final int RC_SIGN_IN = 123;
    private FirebaseAuth mAuth;
    private GoogleSignInClient mGoogleSignInClient;



    @Override
    protected void onStart() {
        super.onStart();

        FirebaseUser user = mAuth.getCurrentUser();
        if(user != null){
            Intent intent = new Intent(getApplicationContext(), home_user.class);
            startActivity(intent);
        }

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_login);

        mAuth = FirebaseAuth.getInstance();

    
    // ________________SIGN IN WITH GOOGLE _____________//

        createRequest();

        findViewById(R.id.google_signIn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                signIn();
            }
        });
    }

    private void createRequest() {
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(getString(R.string.default_web_client_id))
                .requestEmail()
                .build();

        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
    }

    private void signIn() {
        Intent signInIntent = mGoogleSignInClient.getSignInIntent();
        startActivityForResult(signInIntent, RC_SIGN_IN);
    }

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

    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
        if (requestCode == RC_SIGN_IN) {
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
            // Google Sign In was successful, authenticate with Firebase
                GoogleSignInAccount account = task.getResult(ApiException.class);
                //Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());
                firebaseAuthWithGoogle(account.getIdToken());
            } catch (ApiException e) {
                // Google Sign In failed, update UI appropriately
                Log.w("DEBUG", "Google sign in failed", e);
                Toast.makeText(User_login.this,"Google signin failed",Toast.LENGTH_LONG).show();
            }
        }
    }

    private void firebaseAuthWithGoogle(String idToken) {
        AuthCredential credential = GoogleAuthProvider.getCredential(idToken, null);
        mAuth.signInWithCredential(credential)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            // Sign in success, update UI with the signed-in user's information
                            Log.d("DEBUG", "signInWithCredential:success");

                            FirebaseUser user = mAuth.getCurrentUser();
                            Intent intent = new Intent(getApplicationContext(), home_user.class);
                            startActivity(intent);

                        } else {
                            Toast.makeText(User_login.this, "sorry something went wrong, please retry",Toast.LENGTH_LONG).show();
                            // If sign in fails, display a message to the user.
                            //Log.w(TAG, "signInWithCredential:failure", task.getException());

                        }
                    }
                });
    }



}
公共类用户\u登录扩展AppCompative活动{
专用静态最终int RC_SIGN_IN=123;
私人消防队;
私人谷歌签名客户端mGoogleSignInClient;
@凌驾
受保护的void onStart(){
super.onStart();
FirebaseUser=mAuth.getCurrentUser();
如果(用户!=null){
Intent Intent=newintent(getApplicationContext(),home\u user.class);
星触觉(意向);
}
}
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u user\u login);
mAuth=FirebaseAuth.getInstance();
//用谷歌登录_____________//
createRequest();
findViewById(R.id.google_sign).setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图){
签名();
}
});
}
私有void createRequest(){
GoogleSignenOptions gso=新建GoogleSignenOptions.Builder(GoogleSignenOptions.DEFAULT\u登录)
.requestIdToken(getString(R.string.default\u web\u client\u id))
.requestEmail()
.build();
mGoogleSignInClient=GoogleSignIn.getClient(this,gso);
}
私人无效签名(){
Intent-signinint=mGoogleSignInClient.getsigninint();
startActivityForResult(签名、注册);
}
@凌驾
ActivityResult上的公共void(int请求代码、int结果代码、意图数据){
super.onActivityResult(请求代码、结果代码、数据);
//从GoogleSignInApi.getsigninent(…)启动Intent返回的结果;
if(requestCode==RC\u登录){
Task Task=GoogleSignIn.GetSignedAccountFromIntent(数据);
试一试{
//Google登录成功,通过Firebase验证
GoogleSignInAccount account=task.getResult(ApiException.class);
//Log.d(标记为“firebaseAuthWithGoogle:+account.getId());
firebaseAuthWithGoogle(account.getIdToken());
}捕获(APIE){
//Google登录失败,请适当更新UI
Log.w(“调试”,“谷歌登录失败”,e);
Toast.makeText(用户_login.this,“谷歌登录失败”,Toast.LENGTH_LONG.show();
}
}
}
私有void firebaseAuthWithGoogle(字符串idToken){
AuthCredential credential=GoogleAuthProvider.getCredential(idToken,null);
mAuth.SIGNWITH凭证(凭证)
.addOnCompleteListener(这是新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
//登录成功,使用登录用户的信息更新UI
Log.d(“调试”,“使用凭据登录:成功”);
FirebaseUser=mAuth.getCurrentUser();
Intent Intent=newintent(getApplicationContext(),home\u user.class);
星触觉(意向);
}否则{
Toast.makeText(用户_login.this,“抱歉出错,请重试”,Toast.LENGTH_LONG.show();
//如果登录失败,则向用户显示消息。
//w(标记“signInWithCredential:failure”,task.getException());
}
}
});
}
}
编辑:以下是我的logcat错误:

2021-05-09 15:14:57.861 1997-1997/com.covoid.app W/DEBUG:谷歌登录失败 com.google.android.gms.common.api.ApiException:10: 在 com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play services base@@17.1.0:4) 在com.google.android.gms.auth.api.signin.GoogleSignIn.GetSignedAccountFromIntent上(com.google.android.gms:play services auth@@18.1.0:9) 在com.covoid.app.User_login.onActivityResult(User_login.java:137)上 位于android.app.Activity.dispatchActivityResult(Activity.java:8304) 位于android.app.ActivityThread.deliverResults(ActivityThread.java:5136) 位于android.app.ActivityThread.handleSendResult(ActivityThread.java:5184) 在android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 在android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:140)中 在android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:100)中 在android.app.ActivityThread$H.handleMessage(ActivityThread.java:2222) 位于android.os.Handler.dispatchMessage(Handler.java:107) 位于android.os.Looper.loop(Looper.java:228) 位于android.app.ActivityThread.main(ActivityThread.java:7782) 位于java.lang.reflect.Method.invoke(本机方法) 位于com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:981)


在Firebase中检查您是否必须启用google登录

转到firebase身份验证和内部sigin方法启用google登录


“应用程序没有让我登录”,它是否会引发任何错误?有日志吗?你能检查日志并附上t吗