当我尝试通过FirebaseUI用google帐户登录时,总是出现12500错误。另外,如果我尝试通过另一个不是我的Google帐户登录,则会要求我输入密码。我试图写我的密码帐户,但它不接受。
我真的尝试了在网络中找到的所有解决方案。我试图替换和编辑我的google-json文件,更改和编辑我的SHA-1代码,并创建另一个OAuth客户端ID,没有帮助。
public class Login2 extends AppCompatActivity {
List<AuthUI.IdpConfig> providers;
private static final int MY_REQUEST_CODE=1111;
private static final int RC_SIGN_IN=1;
private String TAG="Activity";
FirebaseAuth firebaseAuth;
Button signOut;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login2);
firebaseAuth= FirebaseAuth.getInstance();
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.example.allergyalert",
PackageManager.GET_SIGNATURES);
for (Signature signature : ((PackageInfo) info).signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
signOut=findViewById(R.id.signOutTestBtn);
signOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AuthUI.getInstance().signOut(Login2.this).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
signOut.setEnabled(false);
showSignInOptions();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Login2.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
});
providers= Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build(),
new AuthUI.IdpConfig.FacebookBuilder().build()
);
}
public void showSignInOptions() {
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),
MY_REQUEST_CODE);
}
public void userLoggedIn(){
if(firebaseAuth.getCurrentUser() == null){
showSignInOptions();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==MY_REQUEST_CODE)
{
IdpResponse response= IdpResponse.fromResultIntent(data);
if(resultCode==RESULT_OK)
{
FirebaseUser user= FirebaseAuth.getInstance().getCurrentUser();
Toast.makeText(this, ""+user.getEmail(), Toast.LENGTH_SHORT).show();
signOut.setEnabled(true);
}
else
{
Toast.makeText(this, ""+response.getError().getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
}
答案 0 :(得分:0)
只需将您的Google Play服务更新到最新版本(在这种情况下为11720000)。如果您使用的是AVD,则Nexus 5和5X图像均支持Google Play。模拟器启动并运行后,进入“扩展控件菜单”> Google Play,然后进行更新。
请参阅此链接以获取更多信息:Google Sign In error 12500