Firebase监听器无法正常工作

时间:2013-07-14 16:26:32

标签: android firebase

我正在为Android测试新的Firebase库,不幸的是它无法正常工作,这是我在onCreate MainActivity.method上的代码:

Firebase ref = new Firebase("https://mydatabase.firebaseio.com/");

    // Read data and react to changes
    ref.addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot snap) {
            Log.e("FIREBASE", snap.getName() + " -> " + snap.getValue());
        }

        @Override public void onCancelled() { }
    });

输出:未显示任何消息且调试错误:

07-15 00:01:49.020: D/ActionBarSherlock(13362): [callbackPrepareOptionsMenu] returning true
07-15 00:01:49.020: D/ActionBarSherlock(13362): [dispatchPrepareOptionsMenu] returning true
07-15 00:01:49.370: D/dalvikvm(13362): GC_CONCURRENT freed 263K, 4% free 9700K/10055K, paused 20ms+4ms
07-15 00:01:49.830: D/WebSocket(13362): ws_0 - closed with code -1 and reason: 
07-15 00:01:49.830: D/WebSocket(13362): ws_0 - closing itself
07-15 00:01:49.830: D/Connection(13362): conn_0 - Realtime connection failed
07-15 00:01:49.830: D/Connection(13362): conn_0 - closing realtime connection
07-15 00:01:49.830: D/PersistentConnection(13362): pc_0 - Got on disconnect
07-15 00:01:49.830: D/PersistentConnection(13362): pc_0 - Reconnecting in 0ms
07-15 00:01:49.830: D/ViewManager(13362): Raising events for /.info/connected
07-15 00:01:49.830: D/ViewManager(13362): Marking queries complete for /.info/connected
07-15 00:01:49.830: D/ViewManager(13362): Marking queryMap complete:null
07-15 00:01:49.840: D/Connection(13362): conn_1 - Opening a connection
07-15 00:01:50.670: D/WebSocket(13362): ws_1 - closed with code -1 and reason: 
07-15 00:01:50.670: D/WebSocket(13362): ws_1 - closing itself
07-15 00:01:50.670: D/Connection(13362): conn_1 - Realtime connection failed
07-15 00:01:50.670: D/Connection(13362): conn_1 - closing realtime connection
07-15 00:01:50.670: D/PersistentConnection(13362): pc_0 - Got on disconnect
07-15 00:01:50.670: D/PersistentConnection(13362): pc_0 - Reconnecting in 342ms
07-15 00:01:50.670: D/ViewManager(13362): Raising events for /.info/connected
07-15 00:01:50.670: D/ViewManager(13362): Marking queries complete for /.info/connected
07-15 00:01:50.670: D/ViewManager(13362): Marking queryMap complete:null

PS:我把INTERNET权限放在AndroidManifest文件上。

PS 2:我下载了聊天示例,但它也没有用。

1 个答案:

答案 0 :(得分:1)

这看起来像Android 2.3的SSL实现的问题。我们正在研究围绕它的库的更新。您可以尝试在版本为> = 3.0的模拟器上运行您的应用程序吗?

我们刚刚发布了该库的新版本(v1.0.2)。你可以尝试一下,看看它是否解决了这个问题?它包含一些Android SSL限制的变通方法。

https://www.firebase.com/docs/downloads.html