gpt4 book ai didi

java - Google 登录错误代码 12500,消息 12500

转载 作者:行者123 更新时间:2023-12-02 02:48:27 29 4
gpt4 key购买 nike

I add google sign in my android app but it gives me an error" code:
12500 message:12500"
. I use an external emulator (Samsung Galaxy J7 pro ) for testing. kindly help me, please if I log in with email then works fine kindly ignore the imports .i tried all kind of solution like checking sha-1 fingerprint client id but it does not work

*

这是我的代码

    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)类,其中包含变量

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 Play 服务更新到最新版本。看这个answer

看看这个question还有

关于java - Google 登录错误代码 12500,消息 12500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57126899/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com