11

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);
    progressBar.setVisibility(View.VISIBLE);

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("message");
    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            String value = dataSnapshot.getValue(String.class);
            textView.setText(value);
            progressBar.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onCancelled(DatabaseError error) {
            progressBar.setVisibility(View.INVISIBLE);
        }
    });`

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

7
  • Please share the code the you are using to get the data from the database.
    – Alex Mamo
    Jul 29, 2018 at 10:58
  • @AlexMamo I created whole new application for testing (also shared the code) Same problem is there.
    – akzarma
    Jul 29, 2018 at 14:36
  • fascinating! is this in debug builds or something, does it make any difference ?
    – Fattie
    Jul 30, 2018 at 18:05
  • 2
    @Fattie I've tried on both the builds. it behaves exactly same. (also added the link to project in the question)
    – akzarma
    Jul 30, 2018 at 18:37
  • Not sure how to work around it but one possible reason is SSLHandshakeException caused by CertificateExpiredException.
    – user9782202
    Aug 3, 2018 at 19:27

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.