FirebaseApp.initializeApp(this);
FirebaseAuth.getInstance().deleteUser(uid);
System.out.println("Successfully deleted user.");
In this code,deleteUser(uid)
shows that "Cannot resolve method ‘deleteUser’ in ‘FirebaseAuth’". I don’t know why. My doubt is that: there may be some conflicts between client SDK and service SDK. I have not created my service code and just want to test the function so I write all the code in the client.
I have tried a lot of ways, I want to know what should I do. Thank you guys.
If I need to separate the client and service then will it work?
2
Answers
If you want to write a java program to delete users in Firebase Auth, you must use the Firebase Admin SDK. You can’t use the Android client SDK – it won’t work at all outside of an Android app, and it doesn’t even expose a method to delete a user by UID. I suggest referring to the Firebase Admin documentation on deleting a user.
While @DougStevenson solution solves the problem using the Firebase Admin SDK, please also note that the FirebaseAuth class doesn’t contain any
deleteUser(uid)
method. However, there is a delete() method inside the FirebaseUser class, which:So if you want to delete a user from an Android app, that’s the function that you have to use.
One more thing to notice, the delete operation is an asynchronous operation, so you have to attach a listener to see when the operation is complete or fails with an error.