uPhyca / stetho-realm

Realm module for Stetho
Other
738 stars 114 forks source link

Remote Debugging has been terminated with reason: Connection lost. at runtime #33

Closed mfissehaye closed 8 years ago

mfissehaye commented 8 years ago

I am trying to get categories with this code in my MainActivity class


Realm.init(this);
Realm realm = Realm.getDefaultInstance();
RealmQuery<Category> query = realm.where(Category.class);
RealmResults<Category> categories = query.findAll();

LomiFragmentStatePagerAdapter adapter = new LomiFragmentStatePagerAdapter(getSupportFragmentManager(), categories);
myPager.setAdapter(adapter);

After launching inspect my device from chrome://inspect and trying to expand default.realm under Web SQL it throws error:

Detached from the target
Remote debugging has been terminated with reason: Connection lost.
Please re-attach to the new target.

And the application fails. The application does not normally fail otherwise.

Here is the stack trace from Android Monitor:

09-29 16:23:43.739 30536-9683/com.a360ground.lomibooksrecycler E/AndroidRuntime: FATAL EXCEPTION: StethoWorker-main-938
                                                                                 Process: com.a360ground.lomibooksrecycler, PID: 30536
                                                                                 java.lang.NoClassDefFoundError: Failed resolution of: Lio/realm/internal/SharedGroup;
                                                                                     at com.uphyca.stetho_realm.RealmPeerManager.openSharedGroupForImplicitTransactions(RealmPeerManager.java:145)
                                                                                     at com.uphyca.stetho_realm.RealmPeerManager.openSharedGroupForImplicitTransactions(RealmPeerManager.java:134)
                                                                                     at com.uphyca.stetho_realm.RealmPeerManager.getDatabaseTableNames(RealmPeerManager.java:57)
                                                                                     at com.uphyca.stetho_realm.Database.getDatabaseTableNames(Database.java:125)
                                                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                                                     at com.facebook.stetho.inspector.MethodDispatcher$MethodDispatchHelper.invoke(MethodDispatcher.java:96)
                                                                                     at com.facebook.stetho.inspector.MethodDispatcher.dispatch(MethodDispatcher.java:67)
                                                                                     at com.facebook.stetho.inspector.ChromeDevtoolsServer.handleRemoteRequest(ChromeDevtoolsServer.java:129)
                                                                                     at com.facebook.stetho.inspector.ChromeDevtoolsServer.handleRemoteMessage(ChromeDevtoolsServer.java:111)
                                                                                     at com.facebook.stetho.inspector.ChromeDevtoolsServer.onMessage(ChromeDevtoolsServer.java:87)
                                                                                     at com.facebook.stetho.websocket.WebSocketSession$1.handleTextFrame(WebSocketSession.java:176)
                                                                                     at com.facebook.stetho.websocket.WebSocketSession$1.onCompleteFrame(WebSocketSession.java:136)
                                                                                     at com.facebook.stetho.websocket.ReadHandler.readLoop(ReadHandler.java:44)
                                                                                     at com.facebook.stetho.websocket.WebSocketSession.handle(WebSocketSession.java:45)
                                                                                     at com.facebook.stetho.websocket.WebSocketHandler.doUpgrade(WebSocketHandler.java:117)
                                                                                     at com.facebook.stetho.websocket.WebSocketHandler.handleRequest(WebSocketHandler.java:83)
                                                                                     at com.facebook.stetho.server.http.LightHttpServer.dispatchToHandler(LightHttpServer.java:84)
                                                                                     at com.facebook.stetho.server.http.LightHttpServer.serve(LightHttpServer.java:61)
                                                                                     at com.facebook.stetho.inspector.DevtoolsSocketHandler.onAccepted(DevtoolsSocketHandler.java:52)
                                                                                     at com.facebook.stetho.server.ProtocolDetectingSocketHandler.onSecured(ProtocolDetectingSocketHandler.java:63)
                                                                                     at com.facebook.stetho.server.SecureSocketHandler.onAccepted(SecureSocketHandler.java:33)
                                                                                     at com.facebook.stetho.server.LazySocketHandler.onAccepted(LazySocketHandler.java:36)
                                                                                     at com.facebook.stetho.server.LocalSocketServer$WorkerThread.run(LocalSocketServer.java:167)
                                                                                  Caused by: java.lang.ClassNotFoundException: Didn't find class "io.realm.internal.SharedGroup" on path: DexPathList[[zip file "/data/app/com.a360ground.lomibooksrecycler-2/base.apk"],nativeLibraryDirectories=[/data/app/com.a360ground.lomibooksrecycler-2/lib/x86, /data/app/com.a360ground.lomibooksrecycler-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
                                                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                                     at com.uphyca.stetho_realm.RealmPeerManager.openSharedGroupForImplicitTransactions(RealmPeerManager.java:145) 
                                                                                     at com.uphyca.stetho_realm.RealmPeerManager.openSharedGroupForImplicitTransactions(RealmPeerManager.java:134) 
                                                                                     at com.uphyca.stetho_realm.RealmPeerManager.getDatabaseTableNames(RealmPeerManager.java:57) 
                                                                                     at com.uphyca.stetho_realm.Database.getDatabaseTableNames(Database.java:125) 
                                                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                                                     at com.facebook.stetho.inspector.MethodDispatcher$MethodDispatchHelper.invoke(MethodDispatcher.java:96) 
                                                                                     at com.facebook.stetho.inspector.MethodDispatcher.dispatch(MethodDispatcher.java:67) 
                                                                                     at com.facebook.stetho.inspector.ChromeDevtoolsServer.handleRemoteRequest(ChromeDevtoolsServer.java:129) 
                                                                                     at com.facebook.stetho.inspector.ChromeDevtoolsServer.handleRemoteMessage(ChromeDevtoolsServer.java:111) 
                                                                                     at com.facebook.stetho.inspector.ChromeDevtoolsServer.onMessage(ChromeDevtoolsServer.java:87) 
                                                                                     at com.facebook.stetho.websocket.WebSocketSession$1.handleTextFrame(WebSocketSession.java:176) 
                                                                                     at com.facebook.stetho.websocket.WebSocketSession$1.onCompleteFrame(WebSocketSession.java:136) 
                                                                                     at com.facebook.stetho.websocket.ReadHandler.readLoop(ReadHandler.java:44) 
                                                                                     at com.facebook.stetho.websocket.WebSocketSession.handle(WebSocketSession.java:45) 
                                                                                     at com.facebook.stetho.websocket.WebSocketHandler.doUpgrade(WebSocketHandler.java:117) 
                                                                                     at com.facebook.stetho.websocket.WebSocketHandler.handleRequest(WebSocketHandler.java:83) 
                                                                                     at com.facebook.stetho.server.http.LightHttpServer.dispatchToHandler(LightHttpServer.java:84) 
                                                                                     at com.facebook.stetho.server.http.LightHttpServer.serve(LightHttpServer.java:61) 
                                                                                     at com.facebook.stetho.inspector.DevtoolsSocketHandler.onAccepted(DevtoolsSocketHandler.java:52) 
                                                                                     at com.facebook.stetho.server.ProtocolDetectingSocketHandler.onSecured(ProtocolDetectingSocketHandler.java:63) 
                                                                                     at com.facebook.stetho.server.SecureSocketHandler.onAccepted(SecureSocketHandler.java:33) 
                                                                                     at com.facebook.stetho.server.LazySocketHandler.onAccepted(LazySocketHandler.java:36) 
                                                                                     at com.facebook.stetho.server.LocalSocketServer$WorkerThread.run(LocalSocketServer.java:167) 
                                                                                    Suppressed: java.lang.ClassNotFoundException: io.realm.internal.SharedGroup
                                                                                     at java.lang.Class.classForName(Native Method)
                                                                                     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                                     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                            ... 24 more
                                                                                  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
09-29 16:23:44.203 30536-9840/com.a360ground.lomibooksrecycler E/Surface: getSlotFromBufferLocked: unknown buffer: 0xae434410
09-29 16:23:44.771 30536-30536/com.a360ground.lomibooksrecycler E/ChromeDevtoolsServer: onError: ex=java.io.IOException: socket closed
dvdmunckhof commented 8 years ago

This library is not yet compatible with realm 2.0.0, duplicate of https://github.com/uPhyca/stetho-realm/issues/31. Only solution is to downgrade to 1.2.0 or don't use it.

mfissehaye commented 8 years ago

Thank you @Dennis123789 .. I downgraded to 1.2.0. But now the function call Realm.init is not working. The method name init is not recognized. Do I even have to Realm.init() before other realm function calls; I mean can I just safely comment it out?

dvdmunckhof commented 8 years ago

No, Realm.init(...) was introduced in 2.0.0. You only have to initialize it like this:

RealmConfiguration realmConfig = new RealmConfiguration.Builder(context).build();
Realm.setDefaultConfiguration(realmConfig);

Just look at the older 1.x documentation

mfissehaye commented 8 years ago

What is context? How do I get it in my applciation class

Merhawi Fissehaye ----- Address ----- office: - mob: +251 (0) 97.305.3999 Web:--Email:merhawifissehaye@gmail.com

On Sat, Oct 1, 2016 12:12 PM, Dennis123789 notifications@github.com wrote: No, Realm.init(...) was introduced in 2.0.0. You only have to initialize it like this:

RealmConfiguration realmConfig = new RealmConfiguration.Builder(context).build(); Realm.setDefaultConfiguration(realmConfig);

Just look at the older 1.x documentation

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

P1nGu1n commented 8 years ago

Application inherits from Context, just pass the application object itself using 'this'

dvdmunckhof commented 8 years ago

@P1nGu1n is right, if you need help implementing Realm you should ask elsewhere. This is only for stetho-realm.

zaki50 commented 8 years ago

I've released Stetho-Realm 2.0.0 which supports Realm 2.0.0. Please try that.

I'll close this as a duplicate of #31.

If you have further questions, please use #31.