Support Realm Java 3.7.2
Opened this issue Β· 84 comments
Moved from realm/realm-java#5260
3.7.1+
Workaround for now? To which version must I downgrade?
@LaurieScheepers Stetho-Realm would need to replace LinkView
with OsList
.
@LaurieScheepers with Realm 3.5.0 works fine.
I've created #58, which cover this one. Could you check it?
Thanks for the info. I'll keep an eye out for the next release.
Any updates?
@abou7mied you can use the source code in #58 directly for 3.7.1/3.7.2 (maybe even 4.0.0-RC1)
When opened in Chrome, display a blankγ
Device :
Chrome 61.0.3163.100 x64 on Windows 10
Android 4.2.2
Lib :
io.realm:realm-gradle-plugin:3.7.2
com.facebook.stetho:stetho:1.5.0
com.uphyca:stetho_realm:2.1.0
Application code :
Realm.init(this);
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
Any updates on this?
Yeah any ETA's? I would like to upgrade all my dependencies to the latest versions and not keep old versions just for compatibility's sake. Please guys let me know when the next release will be available where this is fixed?
Yeah, it will be really nice if we can update to latest version (>4.0.0)
repositories {
maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
}
dependencies {
implementation 'com.uphyca:stetho_realm:2.2.2'
}
I published temporary maven repo on my github repository until maintainer coming back. It tested on realm 4.0.0. Please let me know if there is a problem
Edit:
4.2.0 under: 2.2.1
4.2.0 over: 2.2.2 (https://github.com/WickeDev/stetho-realm/pull/1)
@wickedev and @AleksanderMielczarek (I believe you two are responsible for this release) I have test your solution with Realm Java 4.1.1 and so far so good, thanks for your work. Let's hope the maintainer release your version sooner on the official repository. Thanks again.
I'm getting this exception when trying to open a 4.1.1 db :
/REALM_JNI: Exception has been thrown: Realm at path '/.../my_database.realm' already opened with a different schema mode.
@mrp14 Can I get more detail like realm configuration, stetho_realm version for that issue?
I used the 2.2.0 version you published, with Realm 4.1.1 and Stetho Realm 1.5.0. Here is the Realm configuration :
val realmConfiguration = RealmConfiguration.Builder().name("my_database.realm") .schemaVersion(1).migration(MyRealmMigration()).build()
MyRealmMigration.migrate method does nothing.
I do have various active change listeners while trying to open the database using Stetho. Could it be related ?
+1
I also had a problem:
/REALM_JNI: Exception has been thrown: Realm at path '/.../my_database.realm' already opened with a different schema mode.
So, i found solution:
In file RealmPeerManager, method openSharedRealm(String databaseId, @nullable OsRealmConfig.Durability durability),
instead :
return SharedRealm.getInstance(builder.deleteRealmIfMigrationNeeded().build());
need to use:
return SharedRealm.getInstance(builder.build());
@wickedev or @AleksanderMielczarek please make this change to your repo, i'll use it for my proj, thx you for your work.
Works fine for me with 2.2.1 version ! Thanks @AScri @wickedev and @AleksanderMielczarek
I also had a problem:
I use the 2.2.1 version you published, with Realm 3.7.2.
The whole exception:
java.lang.NoSuchMethodError: No interface method getModelList(J)Lio/realm/internal/OsList; in class Lio/realm/internal/Row; or its super classes (declaration of 'io.realm.internal.Row' appears in /data/app/com.xxxx.xxxx.debug-1/split_lib_dependencies_apk.apk)
at com.uphyca.stetho_realm.Database$RowWrapper.getLinkList(Database.java:489)
at com.uphyca.stetho_realm.Database.flattenRows(Database.java:276)
at com.uphyca.stetho_realm.Database.access$300(Database.java:38)
at com.uphyca.stetho_realm.Database$1.handleSelect(Database.java:156)
at com.uphyca.stetho_realm.Database$1.handleSelect(Database.java:136)
at com.uphyca.stetho_realm.RealmPeerManager.executeSQL(RealmPeerManager.java:117)
at com.uphyca.stetho_realm.Database.executeSQL(Database.java:135)
at com.uphyca.stetho_realm.delegate.Database.executeSQL(Database.java:59)
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)
When i'm on a table with no link to another Entity working find (and on table with link and no data).
But this exception appear when i'm on a table with data and a link.
Thanks you again for your previous work!
@fkizewski 2.2.1 supports Realm 4.0.0+
@Zhuinden My bad! Thanks. So, do you know if there is a stetho version for Realm 3.7.2? Or i need to update my Realm database to 4.0.0+?
Thanks
There are so many core fixes in 4.x compared to 3.7.2 that it's probably worth it either way.
I recommend 4.1.1 (current latest)
default.realm' already opened with a different schema mode
in 2.2.1 version. realm 4.1.1
@adigyran please check it out on version 2.2.0. I don't know realm core area. but It was working to me.
@adigyran You need to remove this config line when you init Realm in Application: .deleteRealmIfMigrationNeeded()
It works for me:
- Realm 4.1.1
- Stetho 1.5.0
- Stetho-Realm 2.2.1
What about Realm 4.2.0?
@oligazar Please update a folk from @wickedev to 2.2.2
More detail instead of:
repositories { maven { url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo' } }
replace with this:
repositories { maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' } }
And:
dependencies { compile 'com.facebook.stetho:stetho:1.5.0' compile 'com.uphyca:stetho_realm:2.2.2' }
Hope this can help you!
same error though
What about Realm 4.3.1?
href="Unable to resolve dependency for ':app@sds/compileClasspath': Could not resolve com.uphyca:stetho_realm:2.2.1.">Show Details
I think the general notion is that now that Realm Studio
exists, there is no reason to use Stetho for it.
As far as I know Realm Studio is meant to be used when making use of Realm's Live Object server, am I correct in that assumption?
Thanks for everyone's info. Realm 4.1.1 and Stetho-Realm 2.2.2 is working for me.
@LaurieScheepers Realm Studio works with both Sync and Non-Sync Realms...
Oh, cool. I'm very much used to Stetho, but I'll give Realm Studio a shot!
EDIT: after reading through below responses, it seems I'm still going to stick to Stetho.
@Zhuinden Advantage of Stetho-Realm over Realm Studio for Non-sync realms is that it enables you to view 'live' data while with Realm studio you have to copy the realm file over from the device/emulator to the PC to be able to open it. Or i'm missing something?
Bdw. Stetho-Realm 2.2.2 + Realm 4.3.3 is working for me as well, thanks!
Stetho-Realm 2.2.2 + Realm 4.3.3 with deleteRealmIfMigrationNeeded is not working for me
@daniellfalcao Unfortunately Stetho Realm is not support deleteRealmIfMigrationNeeded until now. If you have a solution, Please fix then send PR to temporary repository(https://github.com/wickedev/stetho-realm).
@wickedev you need to specify the deleteIfMigrationNeeded()
when you open the Shared Realm in https://github.com/WickeDev/stetho-realm/blob/a451369596898a446a54fd4d726c88c85d2b6b39/stetho_realm/src/main/java/com/uphyca/stetho_realm/RealmPeerManager.java#L131-L158
Because it uses a different schema mode: https://github.com/realm/realm-java/blob/f755bbcf7c89223b9c999c40789100d9af648e12/realm/realm-library/src/main/java/io/realm/internal/OsRealmConfig.java#L222-L224
Any update for this deleteIfMigrationNeeded() method?
Honestly anyone could write it, as long as you have the RealmConfiguration
@Oshuremy did not have the time, I did specify above where you'd need to add the modifications to handle it though.
Fixed crash change anything for this "update for this deleteIfMigrationNeeded() method"
repositories {
maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
}
dependencies {
implementation 'com.uphyca:stetho_realm:2.3.0'
}
val realmInspector = RealmInspectorModulesProvider.builder(this)
.withDeleteIfMigrationNeeded(true)
.build()
Stetho.initialize(Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(realmInspector)
.build())
Zhuinden writes this 'withDeleteIfMigrationNeeded' feature. Thank you for your contribution.
stetho_realm:2.3.0 is tested on realm 5.1.0
Working like a charm, thanks a lot both of you
@wickedev can I count on it to work?
realm 3.7.2
java.lang.NoClassDefFoundError: Failed resolution of: Lio/realm/internal/OsSharedRealm;
at com.uphyca.stetho_realm.RealmPeerManager.openSharedRealm(RealmPeerManager.java:155)
at com.uphyca.stetho_realm.RealmPeerManager.openSharedRealm(RealmPeerManager.java:131)
at com.uphyca.stetho_realm.RealmPeerManager.getDatabaseTableNames(RealmPeerManager.java:77)
at com.uphyca.stetho_realm.Database.getDatabaseTableNames(Database.java:146)
at com.uphyca.stetho_realm.delegate.Database.getDatabaseTableNames(Database.java:48)
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.OsSharedRealm" on path: DexPathList[[zip file "/data/app/ru.myapp.app-_n5G71tT84iAjWSjE97Vlg==/base.apk"],nativeLibraryDirectories=[/data/app/ru.myapp.app-_n5G71tT84iAjWSjE97Vlg==/lib/x86, /data/app/ru.myapp.app-_n5G71tT84iAjWSjE97Vlg==/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.uphyca.stetho_realm.RealmPeerManager.openSharedRealm(RealmPeerManager.java:155)
at com.uphyca.stetho_realm.RealmPeerManager.openSharedRealm(RealmPeerManager.java:131)
at com.uphyca.stetho_realm.RealmPeerManager.getDatabaseTableNames(RealmPeerManager.java:77)
at com.uphyca.stetho_realm.Database.getDatabaseTableNames(Database.java:146)
at com.uphyca.stetho_realm.delegate.Database.getDatabaseTableNames(Database.java:48)
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)
@hram Unfortunately, The problem is that some class has changed internally since Realm 4.2.0. Therefore, to use 4.1.x or less, you must use version stetho-realm 2.2.1.
@hram realm/realm-java#5482 SharedRealm
was renamed in OsSharedRealm
in Realm 4.0.0
If you need to support 3.7.2, then you should fork the project and rename OsSharedRealm
to SharedRealm
in your project
I have simple app that can add and delete data from Realm and it is fine working.
gradle: 3.1.2
realm-gradle-plugin: 5.1.0
stetho: 1.5.0
stetho_realm: 2.3.0
this is my Application code that is already added in the manifest..
while my app is running in the emulator i show all the errors in logcat and this is what I get:
and I think there are no errors relating to both stetho and realm. They are just like device errors.
then i try to search for stetho in verbose mode:
and also for realm:
base on those searches I think it is fine..
I try to perform some functions in my app that is running in the emulator and then open chrome://inspect
and plot twist:
I can only see my emulator device and not the app so I can't inspect my database...am I doing wrong in this??
@xamantra I suppose that is not about realm-stetho. did you try to use stetho without realm and stetho?
@xamantra Can you please help me with this issue? https://stackoverflow.com/questions/50700497/how-to-displays-realm-database-content-on-android-device/50701211#50701211
@yozhik It think it is not about realm and stetho .it is your gradle project having an issue..try to 'Clean' or 'Rebuild' your project.
Hello @wickedev , sorry for late reply. I think it is also an emulator issue, because my friend uses genymotion for debugging and it is working for him, and I use Nox emulator and it doesn't work, that is my conclusion right now..
Okay, I tested it with Genymotion and android studio emulator and it both works!!..
Now the only thing I'm honestly wondering about is why we're f***ing around with LinkView and SharedRealm if we could just be using the same RealmConfiguration as we use for getting a Realm instance, then get all this schema data via the DynamicRealm API.
@wickedev I have another problem.
When I click the arrow to the left of 'default.realm' under Web SQL, I get 'connection lost'.
Log below:
12-10 20:33:40.837 21819-23811/com.test.app E/REALM_JNI: jni: ThrowingException 8, Realm at path '/data/data/com.test.app/files/default.realm' already opened with a different schema mode., . Exception has been thrown: Realm at path '/data/data/com.test.app/files/default.realm' already opened with a different schema mode.
@kylin17 well if you are using .deleteIfMigrationNeeded()
then you should also use .withDeleteIfMigrationNeeded()
in Stetho-Realm, see #62 (comment)
If you are NOT using .deleteIfMigrationNeeded()
, then you should NOT use withDeleteIfMigrationNeeded()
.
wickedev Excelent!!
I have the next configuration
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "io.realm:realm-gradle-plugin:5.10.0"
maven {
url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo'
}
implementation 'com.facebook.stetho:stetho:1.5.0'
implementation 'com.uphyca:stetho_realm:2.3.0'
super.onCreate();
Realm.init(this);
RealmConfiguration configuration = new RealmConfiguration.Builder()
.name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(0)
.deleteRealmIfMigrationNeeded()
.build();
Realm realm = Realm.getDefaultInstance();
Realm.setDefaultConfiguration(configuration);
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider
.builder(this)
.withDeleteIfMigrationNeeded(true)
.build())
.build());
realm.close();
@kylin17 well if you are using
.deleteIfMigrationNeeded()
then you should also use.withDeleteIfMigrationNeeded()
in Stetho-Realm, see #62 (comment)If you are NOT using
.deleteIfMigrationNeeded()
, then you should NOT usewithDeleteIfMigrationNeeded()
.
Thank you so much, tested on Realm 5.1
@Override
public void onCreate() {
super.onCreate();
instance = this;
Realm.init(this);
RealmConfiguration realmConfig = new RealmConfiguration.Builder()
.name(staticDB).schemaVersion(0)
.migration(new Migration())
.build();
// Log.i(TAG, realmConfig.getSchemaVersion() + "scheme ver");
Realm.setDefaultConfiguration(realmConfig);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name(staticDB).build();
Realm.setDefaultConfiguration(realmConfiguration);
RealmInspectorModulesProvider realmInspector = RealmInspectorModulesProvider.builder(this)
.build();
Stetho.initialize(Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(realmInspector)
.build());
}
I am working on a react native project with realm 6.0.3. I am getting crash on clicking default.realm in sources tab of developer tools. Below is my code for the integration:
maven {
url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo'
}
debugImplementation 'com.uphyca:stetho_realm:2.3.0';
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
So what's the crash
Ah. It's unfortunate I never took the time to rewrite this thing. Everything that Realm-Stetho does could be done with the DynamicRealm API and I think it wouldn't have this shady "connection lost" issue randomly.
@Zhuinden So, how should I proceed? Would I be able to use stetho-realm or not? And issue is not random. It is occuring everytime I try to open
Well, try to check if you have deleteIfMigrationNeeded
on your RealmConfiguration, because then stetho-realm needs withDeleteIfMigrationNeeded
Planning to support Realm 10? I have
maven {
url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo'
}
debugImplementation 'com.uphyca:stetho_realm:2.3.0';
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
.build());
and getting the following when I expand the DB dropdown in Chrome.
java.lang.NoSuchMethodError: No static method getInstance(Lio/realm/RealmConfiguration;)Lio/realm/internal/OsSharedRealm; in class Lio/realm/internal/OsSharedRealm; or its super classes (declaration of 'io.realm.internal.OsSharedRealm' appears in /data/app/com.fieldmargin.debug-zjYyYGRmgku9SwAzjbyN5Q==/base.apk!classes4.dex)
Used to work just fine with Realm 6 but I have recently upgraded quite a lot of app dependencies.
It mostly depends on whether @wickedev is up for it or no longer maintaining his fork.
Tbh even when I made the 2.3.0 edit, my lingering thought was "this should have been using the DynamicRealm API since 2.0", then this wouldn't be an issue
I'm sorry, but I'm not using realm anymore, and I don't have time to maintain it recently. @Zhuinden I think it's a good idea to create a new fork repository.
Fair enough, it's not a huge issue to be honest since Android Studio provides an easy way to access the realm file and open it in Realm Studio.
@wickedev Did you delete your repository recently? Do you know of any forks of your repository that might still exist? Thanks!
EDIT: Found one: https://github.com/dexcom-inc/stetho-realm
Someone should update it to use DynamicRealm
@TadeasKriz
I was deleted repository accidently, sorry.
@Zhuinden
Could you fork a new repository for maven? I think you are the right person to maintain this project more then me.