0

I'm using Firebase for login in my app and every thing work fine but the problem is when the app go live to google play and install the app from there and create new account Firebase save user information with a b c d e labels instad of the name , email , password .., so when I try to read some value wich labeled as name for the current user the app keep looking for name label to get the value and stuck on label b Which was added after the application was downloaded from google play and never go on.

 loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String email=emailEditText.getText().toString();
                String password=passwordEditText.getText().toString();
                if (!email.equals("")&&!password.equals("")) {
                    if (isValid(email)) {
                    progressBar.setVisibility(View.VISIBLE);
                    loginButton.setEnabled(false);
                    firebaseAuth.signInWithEmailAndPassword(email, password)
                            .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                                @Override
                                public void onComplete(@NonNull Task<AuthResult> task) {
                                    if (task.isSuccessful()) {
                                        if (firebaseAuth.getCurrentUser().isEmailVerified()) {
                                            sendUserData();
                                            Log.d(TAG, "user authraized");
                                        } else {
                                            Toast.makeText(getApplicationContext(), "please Verify your email", Toast.LENGTH_SHORT).show();

                                        }
                                    } else {
                                        Toast.makeText(getApplicationContext(), "something went wrong please check your email or password", Toast.LENGTH_SHORT).show();
                                        progressBar.setVisibility(View.GONE);
                                        loginButton.setEnabled(true);
                                    }
                                }
                            });
                }else {
                        loginButton.setEnabled(true);
                        Toast.makeText(LoginKeyShop.this, "email not vaild!", Toast.LENGTH_SHORT).show();

                    }
                }else {
                    Toast.makeText(LoginKeyShop.this,"please fill the fields ",Toast.LENGTH_SHORT).show();
                    progressBar.setVisibility(View.GONE);
                    loginButton.setEnabled(true);
                }
            }
        }); 

private void sendUserData() {
        databaseReference= FirebaseDatabase.getInstance().getReference("Users");
        databaseReference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for (DataSnapshot snapshot:dataSnapshot.getChildren()){
                    User user=snapshot.getValue(User.class);
                   try {
                       CardHolderData cardHolderData=new CardHolderData();
                       if (user.getUserId().equals(firebaseAuth.getCurrentUser().getUid())){
                           Log.d(TAG,"sendUserData: true condition  if statement");

                               Log.d(TAG,"sending data: normalDATA "+user.getUserId());

                               Log.d(TAG,"sending data: "+user.getUserId().toLowerCase()+"---"+user.getName().toLowerCase()+"---"+user.getMobileNumber().toLowerCase()+"---"+user.getEmail().toLowerCase());

                               userId =user.getUserId();
                               name =user.getName();
                               name = name.replace(" ", "");

                               phoneNumber =user.getMobileNumber();
                               phoneNumber = phoneNumber.replace(" ", "");

                               email =user.getEmail();
                               email = email.replace(" ", "");
                               password=user.getPassword();
                               cardHolderData.setUserId(userId);
                               cardHolderData.setName(name);
                               cardHolderData.setPassword(password);
                               cardHolderData.setEmail(email);
                               cardHolderData.setUserName(name);
                               cardHolderData.setAgent_mast_id(1);

                           Log.d(TAG," match user data "+cardHolderData.getUserId()+" "+cardHolderData.getName()+" "+cardHolderData.getPassword()+" "+ cardHolderData.getEmail()+" "+cardHolderData.getUserName()+" "+cardHolderData.getAgent_mast_id());
                           sendNetworkRequest(cardHolderData);
                           break;
                       }else {
                           Log.d(TAG,"else not match ");
                           Log.d(TAG,"else not match "+firebaseAuth.getCurrentUser().getUid());
                           Log.d(TAG,"else not match "+user.getUserId());
                       }
                   }catch (Exception e){
                       Log.d(TAG,"sendUserData: onDataChange: Exception: "+e.getMessage());
                       Toast.makeText(LoginKeyShop.this,"please check your enternet connection!",Toast.LENGTH_SHORT).show();
                   }
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });

    }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • This **[answer](https://stackoverflow.com/a/60719948/5246885)** might help. – Alex Mamo Mar 23 '20 at 13:58
  • hi Alex Mamo i check the [this question](https://stackoverflow.com/questions/60719791/firebase-firestore-variable-name-changed) also [this one](https://androidpedia.net/en/tutorial/4500/proguard-obfuscating-and-shrinking-your-code) but unfortunately no think work for me so please any help may you offer for me? – Kakaroto Mar 28 '20 at 16:02

0 Answers0