Google 登录错误代码 12500 ,消息 12500
Posted
技术标签:
【中文标题】Google 登录错误代码 12500 ,消息 12500【英文标题】:Google Sign in error code 12500 , message 12500 【发布时间】:2019-11-29 07:13:13 【问题描述】:我在我的 android 应用程序中添加了 google 登录,但它给了我一个错误
" code: 12500 message:12500"
。我使用外部模拟器(三星 Galaxy J7 pro ) 进行测试。请帮助我,如果我用电子邮件登录然后工作 很好,请忽略进口。我尝试了各种解决方案,例如检查 sha-1 指纹客户端 ID,但它不起作用
*
这是我的代码
import com.example.muhammadtehmoor.guardian_module.Model.User;
import com.example.muhammadtehmoor.guardian_module.utils.Common;
import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.IdpResponse;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.PermissionDeniedResponse;
import com.karumi.dexter.listener.PermissionGrantedResponse;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.single.PermissionListener;
import java.util.Arrays;
import java.util.List;
import io.paperdb.Paper;
public class MainActivity extends AppCompatActivity
DatabaseReference user_information;
private static final int MY_REQUEST_CODE = 2552;
List<AuthUI.IdpConfig> providers;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Paper.init(this);
user_information = FirebaseDatabase.getInstance().getReference(Common.USER_INFORMATION);
providers = Arrays.asList(
new AuthUI.IdpConfig.EmailBuilder().build(),
new AuthUI.IdpConfig.GoogleBuilder().build()
);
Dexter.withActivity(this)
.withPermission(Manifest.permission.ACCESS_FINE_LOCATION)
.withListener(new PermissionListener()
@Override
public void onPermissionGranted(PermissionGrantedResponse response)
showSignInOptions();
@Override
public void onPermissionDenied(PermissionDeniedResponse response)
Toast.makeText(MainActivity.this, "you must accept permission to use app", Toast.LENGTH_SHORT).show();
@Override
public void onPermissionRationaleShouldBeShown(PermissionRequest permission, PermissionToken token)
).check();
private void showSignInOptions()
startActivityForResult(AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
.build(),MY_REQUEST_CODE);
@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)
final FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
user_information.orderByKey()
.equalTo(firebaseUser.getUid())
.addListenerForSingleValueEvent(new ValueEventListener()
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
if(dataSnapshot.getValue() == null) // if user is not exit
if(!dataSnapshot.child(firebaseUser.getUid()).exists()) // if key user id is not exist
Common.loggedUser = new User(firebaseUser.getUid() , firebaseUser.getEmail());
// add to the database
user_information.child(Common.loggedUser.getUid())
.setValue(Common.loggedUser);
else //if user is available
Common.loggedUser = dataSnapshot.child(firebaseUser.getUid()).getValue(User.class);
//save UID to Storage to update location from background
// Paper.book().write(common.USER_UID_SAVE_KEY,Common.loggedUser.getUid());
Paper.book().write(Common.USER_UID_SAVE_KEY , Common.loggedUser.getUid() );
updateToken(firebaseUser);
setupUI();
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
);
private void setupUI()
startActivity(new Intent(MainActivity.this, NavActivity.class));
finish();
private void updateToken(final FirebaseUser firebaseUser)
final DatabaseReference tokens = FirebaseDatabase.getInstance().getReference(Common.TOKENS);
FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(new OnSuccessListener<InstanceIdResult>()
@Override
public void onSuccess(InstanceIdResult instanceIdResult)
tokens.child(firebaseUser.getUid())
.setValue(instanceIdResult.getToken());
).addOnFailureListener(new OnFailureListener()
@Override
public void onFailure(@NonNull Exception e)
Toast.makeText(MainActivity.this, "Login Failed", Toast.LENGTH_SHORT).show();
);
这是我的用户类,其中包含 getter 和 setter
package com.example.muhammadtehmoor.guardian_module.Model;
import java.util.HashMap;
public class User
private String uid,email;
private HashMap<String , User> acceptedList; // list user friends
public String getUid()
return uid;
public void setUid(String uid)
this.uid = uid;
public String getEmail()
return email;
public void setEmail(String email)
this.email = email;
public HashMap<String, User> getAcceptedList()
return acceptedList;
public void setAcceptedList(HashMap<String, User> acceptedList)
this.acceptedList = acceptedList;
这是我的通用类,其中包含变量
public class Common
public static final String USER_UID_SAVE_KEY = "SaveUid";
public static final String TOKENS ="Tokens" ;
public static final String FROM_NAME ="FromName" ;
public static final String ACCEPT_LIST = "acceptedList";
public static final String FROM_UID = "FromUid";
public static final String TO_UID = "ToUid";
public static final String TO_NAME = "ToName";
public static final String FRIEND_REQUEST = "FriendRequests" ;
public static String USER_INFORMATION = "UserInformation";
public static User loggedUser;
【问题讨论】:
Google Sign In error 12500的可能重复 【参考方案1】:将您的 Google Play 服务更新到最新版本。 看到这个answer
也可以看到question
【讨论】:
【参考方案2】:检查连接到应用的 Firebase 项目中的 SHA-1 密钥是否与 Android Studio 中的签名密钥匹配。
【讨论】:
android studio 的登录密钥是什么意思 未登录签名。在 Android Studio 的右侧窗格中有 gradle,在应用程序下,您将看到signingReport,运行它,它将显示一个 SHA-1 密钥,将其复制并粘贴到 FIrebase 中,以便您的调试版本的应用程序与 Firebase 一起使用跨度>以上是关于Google 登录错误代码 12500 ,消息 12500的主要内容,如果未能解决你的问题,请参考以下文章
从 Android 登录时,Google OAuth2 返回错误 10 或错误 12500
在最新的 google play 服务中运行时 Google 登录错误 12500
Android Google登录失败com.google.android.gms.common.api.ApiException:12500
com.google.android.gms.common.api.ApiException:12500