for some reason when I try to make a Databasereference it will not show up in my firebase console. I have a android app where I allow user to register/login and when they hit the register button a Databasereference should show up in the console with their userid as a child and they should be logged in. So the users are getting logged in but the Databasereference is writing to console. In the logs im getting a permission denied error. I set my rules to allow read and write so I dont know why that is happening and I made sure the google-services.json is correct for my app. Here is my code below
package com.example.movir;
import androidx.annotation.NonNull;
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class LendersLoginActivity extends AppCompatActivity {
private static final String TAG = "";
private FirebaseAuth mAuth;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lenders_login);
// ...
// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();
final EditText usernameEditText = findViewById(R.id.username);
final EditText passwordEditText = findViewById(R.id.password);
final Button loginButton = findViewById(R.id.login);
final Button registerButton = findViewById(R.id.register_button);
final ProgressBar loadingProgressBar = findViewById(R.id.loading);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = usernameEditText.getText().toString();
String password = passwordEditText.getText().toString();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(LendersLoginActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithEmail:success");
String user_id= mAuth.getCurrentUser().getUid();
DatabaseReference current_user_db = FirebaseDatabase.getInstance().getReference().child("Users").child("Lenders").child(user_id);
current_user_db.setValue(true);
Intent intent = new Intent(LendersLoginActivity.this,LendersMenuPageActivity.class);
startActivity(intent);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithEmail:failure", task.getException());
Toast.makeText(LendersLoginActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
// ...
}
// ...
}
});
}
});
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = usernameEditText.getText().toString();
String password = passwordEditText.getText().toString();
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(LendersLoginActivity.this, new OnCompleteListener< AuthResult >() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
String user_id= mAuth.getCurrentUser().getUid();
DatabaseReference current_user_db = FirebaseDatabase.getInstance().getReference().child("Users").child("Lenders").child(user_id);
current_user_db.setValue(true);
Intent intent = new Intent(LendersLoginActivity.this,LendersMenuPageActivity.class);
Log.d(TAG, "createUserWithEmail:success");
startActivity(intent);
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "createUserWithEmail:failure", task.getException());
Toast.makeText(LendersLoginActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
// ...
}
});
}
});
}
}
Here are my logs
2021-03-14 11:24:05.511 14583-14614/com.example.movir I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to fallback implementation
2021-03-14 11:24:05.583 14583-14614/com.example.movir W/System: Ignoring header X-Firebase-Locale because its value was null.
2021-03-14 11:24:05.599 14583-14614/com.example.movir I/System.out: isEmailSend:POST
2021-03-14 11:24:05.656 14583-14614/com.example.movir I/System.out: port:443
2021-03-14 11:24:05.911 14583-14614/com.example.movir I/System.out: Check isMmsSendPdu
2021-03-14 11:24:05.921 14583-14614/com.example.movir I/System.out: [OkHttp] sendRequest<<
2021-03-14 11:24:06.224 14583-14614/com.example.movir W/System: Ignoring header X-Firebase-Locale because its value was null.
2021-03-14 11:24:06.234 14583-14614/com.example.movir I/System.out: isEmailSend:POST
2021-03-14 11:24:06.242 14583-14614/com.example.movir I/System.out: Check isMmsSendPdu
2021-03-14 11:24:06.248 14583-14614/com.example.movir I/System.out: [OkHttp] sendRequest<<
2021-03-14 11:24:06.418 14583-14614/com.example.movir D/FirebaseAuth: Notifying id token listeners about user ( 5mfvkS1vGndftKXzsE4yUkt4TMC2 ).
2021-03-14 11:24:06.418 14583-14614/com.example.movir D/FirebaseAuth: Notifying auth state listeners about user ( 5mfvkS1vGndftKXzsE4yUkt4TMC2 ).
--------- beginning of system
2021-03-14 11:24:06.488 14583-14712/com.example.movir V/FA: Recording user engagement, ms: 28677
2021-03-14 11:24:06.505 14583-14711/com.example.movir V/FA: onActivityCreated
2021-03-14 11:24:06.517 14583-14712/com.example.movir V/FA: Connecting to remote service
2021-03-14 11:24:06.525 14583-14712/com.example.movir V/FA: Activity paused, time: 1162831406
2021-03-14 11:24:06.533 14583-14769/com.example.movir I/System.out: port:443
2021-03-14 11:24:06.585 14583-14588/com.example.movir I/zygote: Do partial code cache collection, code=124KB, data=113KB
2021-03-14 11:24:06.587 14583-14588/com.example.movir I/zygote: After code cache collection, code=124KB, data=113KB
2021-03-14 11:24:06.587 14583-14588/com.example.movir I/zygote: Increasing code cache capacity to 512KB
2021-03-14 11:24:06.684 14583-14583/com.example.movir V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@2b33e7c[]
2021-03-14 11:24:06.687 14583-14583/com.example.movir D/WindowClient: Add to mViews: DecorView@2b33e7c[LendersMenuPageActivity], this = android.view.WindowManagerGlobal@ed0972b
2021-03-14 11:24:06.691 14583-14583/com.example.movir D/ViewRootImpl[LendersMenuPageActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
2021-03-14 11:24:06.692 14583-14712/com.example.movir V/FA: Connection attempt already in progress
2021-03-14 11:24:06.697 14583-14712/com.example.movir V/FA: Activity resumed, time: 1162831603
2021-03-14 11:24:06.697 14583-14583/com.example.movir V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = ViewRoot{42e658b com.example.movir/com.example.movir.LendersMenuPageActivity,ident = 3}, this = DecorView@2b33e7c[LendersMenuPageActivity]
2021-03-14 11:24:06.798 14583-14583/com.example.movir D/Surface: Surface::allocateBuffers(this=0x982b7000)
2021-03-14 11:24:06.798 14583-14622/com.example.movir D/Surface: Surface::connect(this=0x982b7000,api=1)
2021-03-14 11:24:06.805 14583-14622/com.example.movir D/Surface: Surface::setBufferCount(this=0x982b7000,bufferCount=4)
2021-03-14 11:24:06.852 14583-14712/com.example.movir V/FA: Connection attempt already in progress
2021-03-14 11:24:06.858 14583-14712/com.example.movir V/FA: Connection attempt already in progress
2021-03-14 11:24:06.941 14583-14712/com.example.movir D/FA: Connected to remote service
2021-03-14 11:24:06.946 14583-14712/com.example.movir V/FA: Processing queued up service tasks: 4
2021-03-14 11:24:06.957 14583-14622/com.example.movir E/[EGL-ERROR]: __egl_platform_cancel_buffers:644: surface->num_buffers(4)
2021-03-14 11:24:06.958 14583-14622/com.example.movir D/Surface: Surface::disconnect(this=0x981ff000,api=1)
2021-03-14 11:24:07.317 14583-14583/com.example.movir V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = ViewRoot{86bcf3f com.example.movir/com.example.movir.LendersLoginActivity,ident = 1}, this = DecorView@6c705e0[LendersLoginActivity]
2021-03-14 11:24:08.048 14583-14767/com.example.movir W/RepoOperation: setValue at /Users/Lenders/5mfvkS1vGndftKXzsE4yUkt4TMC2 failed: DatabaseError: Permission denied
2021-03-14 11:24:12.054 14583-14712/com.example.movir V/FA: Inactivity, disconnecting from the service
2021-03-14 11:24:12.061 14583-14712/com.example.movir W/System.err: java.lang.IllegalArgumentException: Service not registered: lg@bde9d9a
2021-03-14 11:24:12.063 14583-14712/com.example.movir W/System.err: at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1494)
2021-03-14 11:24:12.065 14583-14712/com.example.movir W/System.err: at android.app.ContextImpl.unbindService(ContextImpl.java:1655)
2021-03-14 11:24:12.067 14583-14712/com.example.movir W/System.err: at android.content.ContextWrapper.unbindService(ContextWrapper.java:712)
2021-03-14 11:24:12.068 14583-14712/com.example.movir W/System.err: at ci.f(:com.google.android.gms.dynamite_measurementdynamite@210613128@21.06.13 (110306-0):0)
2021-03-14 11:24:12.070 14583-14712/com.example.movir W/System.err: at ci.d(:com.google.android.gms.dynamite_measurementdynamite@210613128@21.06.13 (110306-0):2)
2021-03-14 11:24:12.071 14583-14712/com.example.movir W/System.err: at lh.D(:com.google.android.gms.dynamite_measurementdynamite@210613128@21.06.13 (110306-0):9)
2021-03-14 11:24:12.072 14583-14712/com.example.movir W/System.err: at kr.a(:com.google.android.gms.dynamite_measurementdynamite@210613128@21.06.13 (110306-0):3)
2021-03-14 11:24:12.074 14583-14712/com.example.movir W/System.err: at ef.run(:com.google.android.gms.dynamite_measurementdynamite@210613128@21.06.13 (110306-0):3)
2021-03-14 11:24:12.075 14583-14712/com.example.movir W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
2021-03-14 11:24:12.076 14583-14712/com.example.movir W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2021-03-14 11:24:12.077 14583-14712/com.example.movir W/System.err: at im.run(:com.google.android.gms.dynamite_measurementdynamite@210613128@21.06.13 (110306-0):5)