首页 > 解决方案 > 我以前在 Android Studio 的 FirebaseAuth 中从未见过这样的错误

问题描述

我正在处理 SignUpActivity。

我以前做过这个工作,但我没有收到这种类型的错误。

这是我的注册活动:

public class SignUpActivity extends AppCompatActivity {

    ActivitySignUpBinding binding;
    private FirebaseFirestore firestore;
    private FirebaseAuth auth;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySignUpBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        //I erased the methods and more codes and I just keep it simple for you to understand the code. 
        //but if you run this code then it will give you an error.

        //main error this below code giving
        auth = FirebaseAuth.getInstance();
        firestore = FirebaseFirestore.getInstance();
     }
}

这是我的日志:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vishal.kaitka.openqadmin, PID: 7293
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app.myapp/com.example.app.myapp.SignUpActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.app.myapp. Make sure to call FirebaseApp.initializeApp(Context) first.

标签: javaandroidfirebase-authentication

解决方案


推荐阅读