Error getReference (). child () with firebase

0

I'm doing a chat example using Firebase and I have the following error.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.yordy.richard.firebaseejemplo, PID: 23054
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.yordy.richard.firebaseejemplo/com.yordy.richard.firebaseejemplo.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.storage.StorageReference com.google.firebase.storage.FirebaseStorage.getReference()' on a null object reference
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2684)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2751)
    at android.app.ActivityThread.-wrap12(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6186)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
 Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.storage.StorageReference com.google.firebase.storage.FirebaseStorage.getReference()' on a null object reference
    at com.yordy.richard.firebaseejemplo.MainActivity.onCreate(MainActivity.java:101)
    at android.app.Activity.performCreate(Activity.java:6684)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2637)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2751) 
    at android.app.ActivityThread.-wrap12(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1496) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:154) 
    at android.app.ActivityThread.main(ActivityThread.java:6186) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 

Inside the error an error I find that I have the following error in a line

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.storage.StorageReference com.google.firebase.storage.FirebaseStorage.getReference()' on a null object reference
        at com.yordy.richard.firebaseejemplo.MainActivity.onCreate(MainActivity.java:101)

One part of the code is as follows

mFirebaseDatabase = FirebaseDatabase.getInstance();
mMessagesDatabaseReference = mFirebaseDatabase.getReference().child("message");
//Storage
mChatPhotosStorageReference = mFirebaseStorage.getReference().child("chat_photos");


mFirebaseAuth = FirebaseAuth.getInstance();

line 101 is as follows

mChatPhotosStorageReference = mFirebaseStorage.getReference().child("chat_photos");
    
asked by Richard Yordy 27.11.2018 в 15:11
source

0 answers