0

As the title says, I use Firebase and I use the instruction "setPersistance" to save the user data offline. I've wrote this instruction in the splash screen of my app, this way I'm sure that I never call other instance of Firebase before. But I don't know why it crash on some devices, the log says:

Calls to setPersistenceEnabled() must be made before any other usage of FirebaseDatabase instance.

Exist some try catch() to avoid this crashes?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Zaitung
  • 53
  • 8
  • 1
    It's impossible to say much without seeing the [minimal code that reproduces the problem](http://stackoverflow.com/help/mcve). But in general the solution is to do what [other developers who encountered this error](http://stackoverflow.com/search?q=%5Bfirebase%5D++Calls+to+setPersistenceEnabled%28%29+must+be+made+before+any+other+usage+of+FirebaseDatabase+instance.) did. The answers here looks especially promising: http://stackoverflow.com/questions/37448186/setpersistenceenabledtrue-crashes-app – Frank van Puffelen Oct 30 '16 at 21:09
  • You can use one of the 2 first answers in this post: http://stackoverflow.com/questions/37753991/com-google-firebase-database-databaseexception-calls-to-setpersistenceenabled/37766261#37766261 – Rosário Pereira Fernandes Feb 01 '17 at 12:53

0 Answers0