5

I followed the docs for Firebase Auth and Database.

Everything works fine after a fresh install:

The user can register or log in, the data is retrieved like it should, written like it should, super fast, super clean. yay.

And then, after a few restarts via android Studio, the database stuff does not work anymore. The amount of restarts varies, I could not find a rule or such. If I uninstall and reinstall the apk (still via Android Studio) it works again.

I'm monitoring the auth state, the user stays logged in, there are also no firebase error at all.

I get a ton of E/DynamiteModule: Failed to load module descriptor class: but apparently this is not an error (just mentioning it because I get 20+ consecutive lines of that "error".

Any idea where I should start looking?

app.gradle

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        ...
        minSdkVersion 15
        targetSdkVersion 23
        ...
    }
    ...
}
...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.google.firebase:firebase-core:9.0.1'
    compile 'com.google.firebase:firebase-database:9.0.1'
    compile 'com.google.firebase:firebase-storage:9.0.1'
    compile 'com.google.firebase:firebase-auth:9.0.1'
    compile 'com.google.firebase:firebase-messaging:9.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
    compile 'cn.pedant.sweetalert:library:1.3'
    testCompile 'junit:junit:4.12'
}

Firebase database rules

{
  "rules": {
    ".read": "auth != null",
    ".write": "auth != null"
  }
}
Community
  • 1
  • 1
Barthy
  • 3,151
  • 1
  • 25
  • 42
  • 1
    Do you have `CompletionListeners` on your setValue() calls, and in the failed state they never fire? Do you have a [listener](https://firebase.google.com/docs/database/android/offline-capabilities#section-connection-state) for ".info/connected" that is reporting loss of connection? – Bob Snyder Jun 09 '16 at 16:50
  • @qbix thank! I'll look into that and come back to you! – Barthy Jun 09 '16 at 17:36
  • @qbix It happened again and the listener showed that the `.info/connected` bit was set to false. There was no error though. – Barthy Jun 09 '16 at 18:57
  • The Firebase debug logs are very detailed and would likely provide some explanation for the connection problem. Enable debug level logging using `FirebaseDatabase.getInstance().setLogLevel(Logger.Level.DEBUG)` and examine the logcat output at the time you lose connection. Post the section of interest if you want help reviewing it. – Bob Snyder Jun 10 '16 at 03:44

1 Answers1

2

It sounds like you may be experiencing a known problem caused with auth token refresh failure discussed here. Try enabling debug level logging using FirebaseDatabase.getInstance().setLogLevel(Logger.Level.DEBUG) and compare the output with the samples included in the discussion linked above. In particular, look for "Error fetching token: An internal error has occured. [ Internal error. ]". If you see that, follow the instructions provided here to fix your google-services.json file.

Bob Snyder
  • 37,759
  • 6
  • 111
  • 158
  • Quick update: I had to switch phones because I broke, one could say destroyed, my oneplus one. So I switched from android 6.0 to 4.3 and I did not have the problem since. – Barthy Jun 12 '16 at 11:11
  • There it happened again and what you suggested seems to have worked! I thank you very much for your help! I'll keep an eye on it and come back to accept and give you the bounty if this permanently solves the problem :) – Barthy Jun 12 '16 at 15:53