0

I have Realm database on Android phone. And I am trying to save data to Realm database and then to fetch it from there. But I am not sure that I am doing it rightly, because it does not contain some data. I want to see that records in their raw state to understand where am I wrong. But gradle failing to build project on this. Does anybody know how to see with data with some other tools? Thanks. gradle-4.4.1

    io.realm:realm-gradle-plugin:5.1.0
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.uphyca:stetho_realm:2.2.0'

Stetho.initialize(
                Stetho.newInitializerBuilder(this)
                        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
                        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
                        //.enableWebKitInspector(RealmInspectorModulesProvider.builder(this).build())
                        .build());


buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://maven.google.com'
        }
        maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
    }
}
apply plugin: 'com.android.application' //here shows error: Failed to resolve: com
apply plugin: 'io.fabric'

android {
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
yozhik
  • 4,644
  • 14
  • 65
  • 98

2 Answers2

4

As per this issue, Stetho-Realm works with Realm 4.0.0+ if you use the newer version managed by WickeDev:

repositories {
    mavenCentral()
    maven {
        url 'https://maven.google.com'
    }
    jcenter()
    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())
EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428
  • Still not working. I updated my answer with error message: Failed to resolve: com – yozhik Jun 05 '18 at 13:57
  • Okay, that is a completely different problem and I don't know how you broke your Gradle project so much :D – EpicPandaForce Jun 05 '18 at 14:20
  • I've had to add `.withDeleteIfMigrationNeeded(true)` otherwise the connection drops when you click on the Realm database on Chrome (says 'Connection lost') – Albert Vila Calvo Nov 19 '18 at 10:45
  • @EpicPandaForce, I am getting Connection error, can you tell me the solution? – Jay Dangar May 02 '19 at 16:47
  • @JayDangar Well it depends on whether you have `deleteIfMigrationNeeded` set or not. Also you should use `2.3.0` if your version is Realm 4.0.0+. If it's Realm 3.7.2, then you're kinda screwed though, there is no version of Stetho-Realm that supports it and you would need to build it yourself – EpicPandaForce May 02 '19 at 16:56
  • yes, i have set this and using 2.3.0. still not able to find the solution. realm version is 4.0+. – Jay Dangar May 02 '19 at 16:57
  • @EpicPandaForce, can you look into this question? https://stackoverflow.com/q/55957151/6025718 – Avi Patel May 02 '19 at 17:03
  • It is true, in this day and age, you might want to use Realm Studio instead. – EpicPandaForce Apr 23 '21 at 12:45
2

There is another manual way to view records of Realm database but you need Mac OS for that.

1- Run your app in emulator.

2- Go to Tools -> Android Device Monitor

3- Find your app's package name, now you can see all files of your app.

4- Find realm file and Copy it by exporting it to your computer.

5- Now install Realm Browser on MAC OS.

6- Open copied file of database via Realm browser.

You can see all tables and records of your database.