0

Hello guys I'm trying to add firebase to my app but stops working on Emulator when run

my logs:

03-21 09:14:40.581 6568-6568/com.example.fireproject E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.fireproject, PID: 6568
java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.fireproject. Make sure to call FirebaseApp.initializeApp(Context) first.
    at com.google.firebase.FirebaseApp.getInstance(SourceFile:218)
    at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
    at com.example.fireproject.MainActivity$1.onClick(MainActivity.java:31)
    at android.view.View.performClick(View.java:4756)
    at android.view.View$PerformClick.run(View.java:19749)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5221)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
MD Naseem Ashraf
  • 1,030
  • 2
  • 9
  • 22
onur
  • 41
  • 1
  • 4
  • Possible duplicate of [Default FirebaseApp is not initialized](https://stackoverflow.com/questions/40081539/default-firebaseapp-is-not-initialized) – Atef Hares Mar 21 '19 at 09:37

1 Answers1

0

First try to use emulator that is backed with google-play-services, check this


Also As crash explains, try to call

FirebaseApp.initializeApp(Context)

before using firebase instance in you activity, you can this in your Application class onCreate method like this:

FirebaseApp.initializeApp(getBaseContext())

And make sure that you correctly apply the Latest google-play-services plugin

Atef Hares
  • 4,715
  • 3
  • 29
  • 61