我正在尝试从数据库中的引用读取值。它曾经工作但有一天它没有任何理由停止工作。 ValueEventListener设置成功,但我的问题是,它永远不会被调用。
我的代码:
DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("key");
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
int value = snapshot.getValue(Integer.class);
}
@Override
public void onCancelled(DatabaseError error) {}
});
我还注意到每5-10秒写一条消息就会记录
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
还有这个,不确定是否有链接
W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000015/n/arm64-v8a
App-level gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-core:10.2.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
你知道为什么停止工作吗?