Skip to main content

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.auth.FirebaseUser.getUid()' on a null object reference

This error commonly occur in Firebase ,when we are tring to call the mAuth.getCurrentUser().getUid(); which is initialized otside the caller Function. To fix this error we have to initialize this" mAuth.getCurrentUser().getUid(); "inside the Caller Function.
In my case if String id = mAuth.getCurrentUser().getUid(); is declared outside the mAuth.createUserWithEmailAndPassword(emaill,pass).addOnCompleteListener(new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if(task.isSuccessful()) {}); function then....the Attempt to invoke virtual method ......error occur...

Comments

Popular posts from this blog

JAVA DATABASE CONNECTIVITY

Java DataBase Connectivity JDBC stands for Java Database Connectivity. JDBC is a Java API to connect and execute the query with the database. It is a part of JavaSE (Java Standard Edition). JDBC API uses JDBC drivers to connect with the database. There are four types of JDBC drivers: o JDBC-ODBC Bridge Driver, o Native Driver, o Network Protocol Driver, and o Thin Driver We can use JDBC API to access tabular data stored in any relational database. By the help of JDBC API, we can save, update, delete and fetch data from the database. It is like Open Database Connectivity (ODBC) provided by Microsoft.                                         fig: JDBC  We can use JDBC API to handle database using Java program and can perform the following activities: 1. Connect to the database 2. Execute queries and update statements to the database 3. Retrieve the result received from th...

React Today and Tomorrow and 90% Cleaner React With Hooks