question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on getting Realtime Database reference in service

See original GitHub issue

I am getting error:

06-24 10:41:36.497 17316-17316/com.example.waseem.geolocation:location_service E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.waseem.geolocation:location_service, PID: 17316 java.lang.RuntimeException: Unable to instantiate service com.example.waseem.geolocation.LocationService: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn’t exist. at android.app.ActivityThread.handleCreateService(ActivityThread.java:3085) at android.app.ActivityThread.access$1900(ActivityThread.java:172) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1505) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5832) 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:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn’t exist. at com.google.firebase.FirebaseApp.getInstance(Unknown Source) at com.google.firebase.FirebaseApp.getInstance(Unknown Source) at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source) at com.example.waseem.geolocation.LocationService.<init>(LocationService.java:34) at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.Class.newInstance(Class.java:1650) at android.app.ActivityThread.handleCreateService(ActivityThread.java:3082) at android.app.ActivityThread.access$1900(ActivityThread.java:172)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1505)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:145)  at android.app.ActivityThread.main(ActivityThread.java:5832)  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:1399)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) `.

on

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

statement in service but its works fine in activity.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
samtsterncommented, Jun 27, 2016

@ch-muhammad-adil is the service running in the same process as your Activity? If it’s not, you would have an android:process="..." entry in the AndroidManfiest.xml for the service.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error on getting Realtime Database reference in service
DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference();. statement in service but its works fine in activity. Google Cloud Collective.
Read more >
Firebase.Database.DatabaseError Class Reference
Instances of DatabaseError are passed to callbacks when an operation failed. They contain a description of the specific error that occurred.
Read more >
Reading and writing to Realtime Database - Packt Subscription
Writing into Realtime Database. Fetch an instance of your database employing getInstance() and reference the location you need to write.
Read more >
Getting data | Firestore - Google Cloud
By default, a get call will attempt to fetch the latest document snapshot from your database. On platforms with offline support, the client...
Read more >
How to Retrieve Data from the Firebase Realtime Database in ...
Inside that column Navigate to Firebase Realtime Database. Click on that option and you will get to see two options on Connect app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found