无法连接到 signup/in activity 中的数据库。火力地堡 - 9.0.0

Can't get connection to the database in signup/in activity. Firebase - 9.0.0

已更新说明

如何在用户注册的同时将用户发送到数据库。在我的旧代码中工作但现在不行了,我错过了什么?

当用户登录时以及我在 mainActivy() 中开始对用户进行地理标记时,它会与数据库建立连接。但是我需要在用户注册并登录时立即保存它。所以我的登录中的代码有问题activity。

登录Activity:

mAuthListener = new FirebaseAuth.AuthStateListener() {
    @Override
    public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
        FirebaseUser user = firebaseAuth.getCurrentUser();
        if (user != null) {
            // User is signed in
            Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());

            DatabaseReference ref = FirebaseDatabase.getInstance().getReference(); 

            // Authenticated successfully with authData
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("email", email);
            ref.child("users").child(user.getUid()).updateChildren(map);  


            Intent intent = new Intent(LoginActivity.this, MainReal.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);

        } else {
            // User is signed out
            Log.d("TAG", "onAuthStateChanged:signed_out");
        }
    }
};

依赖项

compile "com.google.firebase:firebase-database:9.0.0"
compile 'com.google.firebase:firebase-auth:9.0.0'
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile 'com.firebaseui:firebase-ui-auth:0.4.0'

问题是 String emailnull

下面解决了问题

map.put("email", user.getEmail());