Home » Android » android – Why Firebase stops syncing when local date of device is changed explicitly?

android – Why Firebase stops syncing when local date of device is changed explicitly?

Posted by: admin May 14, 2020 Leave a comment


When I change my Phone’s Local Date setting by 1 or more months and then after restarting my android app which uses Firebase real time database, it doesn’t load the data from database and keeps on loading forever.
Why does this happen? Does Firebase checks the local time of device before fetching the data?

This is onCreate() MainActivity of Android App

After changing the date (by 10 or more days) in settings and then closing and reopening the app, the progress bar never gets invisible.
Not even the onCancelled function get called.

    final ProgressBar progressBar = findViewById(R.id.progress_bar);
    final TextView textView = findViewById(R.id.textView);

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");
    myRef.addValueEventListener(new ValueEventListener() {
        public void onDataChange(DataSnapshot dataSnapshot) {
            String value = dataSnapshot.getValue(String.class);

        public void onCancelled(DatabaseError error) {

App level gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.akzarma.testapplication"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.firebase:firebase-database:11.8.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

apply plugin: 'com.google.gms.google-services'

Below is the Github repistory link for this project, this is just a sample application which fetchs data from firebase realtime databse.: https://github.com/akzarma/testApp

How to&Answers:

As mentioned in the comments, the most likely reason has to do with SSL. SSL does not play nice with incorrect dates therefore it can not connect securely to Firebase. One possible way around this is to connect to Firebase via http but 1) It is not secure 2) I am not sure if it is still supported.