title: Firebase android works on the emulator but not on the device
body: <p>I am new to android and I was able to setup the firebase for my app in kotlin. If i run the app in the <strong>Nexus 5X API 27</strong> emulator I am able to get the database but when i run the app in the actual device <strong>SAMSUNG S5</strong> (Google play Services V 12.5.29, android V 5.0) i don't get the <strong><em>addValueEventListener</em></strong> call back.</p>
  
  <pre><code>ref = FirebaseDatabase.getInstance().reference
      ref!!.addValueEventListener(object : ValueEventListener {
          override fun onCancelled(p0: DatabaseError?) {
              Log.d("firebase", "cancelled")
  
          }
  
          override fun onDataChange(p0: DataSnapshot?) {
  
              if (p0!!.exists()){
                  Log.d("firebase", "date = $p0")
              } else {
                  Log.d("firebase", "no data")
              }
  
          }
  
      })
  </code></pre>
  
  <p>Gradle file: </p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  apply plugin: 'kotlin-android'
  
  apply plugin: 'kotlin-android-extensions'
  
  
  android {
      compileSdkVersion 26
      defaultConfig {
          applicationId "com.example.wonder"
          minSdkVersion 21
          targetSdkVersion 21
          versionCode 1
          versionName "1.0"
          multiDexEnabled true
          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 "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
  implementation 'com.android.support:appcompat-v7:26.1.0'
  implementation 'com.android.support:support-v4:26.1.0'
  implementation 'com.android.support:design:26.1.0'
  implementation 'com.android.support.constraint:constraint-layout:1.0.2'
  implementation 'com.google.firebase:firebase-messaging:11.2.2'
  implementation 'com.google.firebase:firebase-database:11.2.2'
  testImplementation 'junit:junit:4.12'
  androidTestImplementation 'com.android.support.test:runner:1.0.1'
  androidTestImplementation 'com.android.support.test.espresso:espresso- 
  core:3.0.1'
  
  //implementation 'com.google.android.gms:play-services-maps:11.2.2'
  implementation 'com.android.support:recyclerview-v7:26.1.0'
  
  implementation 'com.google.firebase:firebase-core:11.2.2'
  //    implementation 'com.google.android.gms:play-services-ads:12.0.0'
  }
  apply plugin: 'com.google.gms.google-services'
  </code></pre>
  
  <p>I know its not database rule issue because they are set to public.</p>
  
  <p>If you have any suggestions please let me know.</p>
  
  <p>Thanks</p>
  
  <p>EDIT: I do have permissions added in the manifest file</p>
  
  <p><strong>Update: Looks like its working for the device, I just have to wait for 30 minutes. I left the device and came back after a while and the data was there. Could it be threading issue? I am not doing any threading, thought Firebase handles it by itself.</strong> </p>