Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore Token retrieval failed: INVALID_SENDER

I am not receiving any callback from interfaces such as addOnSuccessListener, addOnFailureListener,addOnCompleteListener.

Dependencies:

        classpath 'com.google.gms:google-services:3.2.1'

        implementation 'com.google.firebase:firebase-firestore:16.0.0'
       // }
        apply plugin: 'com.google.gms.google-services'

Code:

 firestore = FirebaseFirestore.getInstance(); // required for first time 
    FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
            .setTimestampsInSnapshotsEnabled(true)
            .build();
    firestore.setFirestoreSettings(settings);

    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Map<String, Object> user = new HashMap<>();
            user.put("Title", "Ada");
            user.put("category", "Lovelace");
            user.put("id", "123");

            firestore = FirebaseFirestore.getInstance();
            firestore.collection("quotes")
                    .add(user)
                    .addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
                        @Override
                        public void onSuccess(DocumentReference documentReference) {
                            Log.d("quotes", "DocumentSnapshot added with ID: " + documentReference.getId());
                            Snackbar.make(fab, "DocumentSnapshot added with ID: " + documentReference.getId(), Snackbar.LENGTH_INDEFINITE).show();
                        }
                    })
                    .addOnFailureListener(new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {
                            Log.w("quotes", "Error adding document", e);
                            Snackbar.make(fab, "OnFailureListener: " + e, Snackbar.LENGTH_INDEFINITE).show();
                        }
                    })
                    .addOnCompleteListener(new OnCompleteListener<DocumentReference>() {
                        @Override
                        public void onComplete(@NonNull Task<DocumentReference> task) {
                            Snackbar.make(fab, "OnCompleteListener: " + task.isSuccessful(), Snackbar.LENGTH_INDEFINITE).show();

                        }
                    });

        }
    });

LOGCAT

E/FirebaseInstanceId: Token retrieval failed: INVALID_SENDER
E/FirebaseInstanceId: Token retrieval failed: INVALID_SENDER
E/FirebaseInstanceId: Token retrieval failed: INVALID_SENDER
like image 449
Aks4125 Avatar asked Jun 22 '18 11:06

Aks4125


1 Answers

If you have recently change your google-services.json file then just delete build folder from android project and re-build your project.

like image 183
Milan Sheth Avatar answered Sep 27 '22 23:09

Milan Sheth