0

I am having trouble using Stetho to view my Realm database in Chrome. I looked at this stackoverflow answer and have gotten to the point of the image in the second link. In the spot where it says inspect, on my computer it has nothing. It just shows the name of the emulator with no inspect button. I was able to get the inspect button before, but it has not been working. If someone could help that would be appreciated greatly!

Remote Target

LOCALHOST

Android SDK built for x86 #EMULATOR-5554

How to view my Realm file in the Realm Browser?

https://i.stack.imgur.com/qWtv2.png

Edit

App Build.gradle

    apply plugin: 'com.android.application'
    apply plugin: 'realm-android'

android {
compileSdkVersion 25
buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "com.example.android.chargerpoints"
    minSdkVersion 17
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

ext {
supportLibVersion = '25.0.0'
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"

// Gradle dependency on Stetho
compile 'com.facebook.stetho:stetho:1.4.1'
compile 'com.uphyca:stetho_realm:2.0.0'


}

repositories{
maven {
    url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
}
}

Project build.gradle

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'
    classpath "io.realm:realm-gradle-plugin:2.3.0"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

}
}

allprojects {
repositories {
        jcenter()
    }
}

task clean(type: Delete) {
delete rootProject.buildDir
}

MyApplication.java

package com.example.android.chargerpoints;

import android.app.Application;

import com.facebook.stetho.Stetho;
import com.uphyca.stetho_realm.RealmInspectorModulesProvider;

import io.realm.Realm;
import io.realm.RealmConfiguration;

public class MyApplication extends Application{

@Override
public void onCreate() {
    super.onCreate();

    Realm.init(this);

    RealmConfiguration config = new RealmConfiguration.Builder()
            .name("Chargers.realm")
            .schemaVersion(1)
            .build();

    Realm.setDefaultConfiguration(config);

    // Use the config
    Realm realm = Realm.getInstance(config);

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

    realm.close();
}
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.chargerpoints">

<application
    android:name= "MyApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".CouponsActivity"
        android:label="@string/title_coupons"
        android:parentActivityName = ".MainActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity"/>
    </activity>

    <activity android:name=".MyDealsActivity"
        android:label="@string/title_my_deals"
        android:parentActivityName=".MainActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity"/>
    </activity>

    <activity android:name=".IndividualCouponActivity"
        android:label="@string/title_individual_coupon"
        android:parentActivityName=".MainActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity"/>
    </activity>

    <activity android:name=".HelpActivity"
        android:label="@string/title_help"
        android:parentActivityName=".MainActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity"/>
    </activity>

    <activity android:name=".RedeemedCouponActivity"
        android:label="@string/title_redeemed_coupon"
        android:parentActivityName=".MainActivity">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".MainActivity"/>
    </activity>

</application>

Community
  • 1
  • 1
J bouse
  • 33
  • 8
  • Yeah i had same problem before. My solution is using debug to query Realm request to show what you want. Or take a look: http://scand.com/products/realmbrowser/ – Harry T. Feb 06 '17 at 02:30

1 Answers1

0

You seem to be conflating a couple of things: Stetho and the Realm Browser. The Realm Browser is an OSX utility used to view Realm databases. If you are using OSX, get the browser from the App Store and then use adb to pull the database from your device/emulator as described here.

If you are not using OSX, you may be able to browse the db from the device/emulator itself, using this library.

Finally, there is a Stetho plugin for Realm, here. You will have to add it to your application, along with the Stetho libraries, to use it. The documentation for both libraries is pretty good.

Community
  • 1
  • 1
G. Blake Meike
  • 6,615
  • 3
  • 24
  • 40
  • I added the stetho plugin for Realm and I had it working before where I go on chrome and look at the developer's tools and click inspect. But the inspect button just doesn't appear anymore. I have been trying every possible option but nothing works – J bouse Feb 09 '17 at 20:16
  • Are you using the Realm plugin? – G. Blake Meike Feb 09 '17 at 22:52
  • Yes I am using the Realm plugin – J bouse Feb 10 '17 at 16:31
  • Is your application built with the Stetho and Realm plugins? – G. Blake Meike Feb 10 '17 at 18:39
  • Yes that i am aware of. I can post the code bits I added – J bouse Feb 10 '17 at 22:32
  • And the weird thing about this is that I had it working perfectly for a few days and it just stopped and I haven't been able to get it to start working again. – J bouse Feb 10 '17 at 22:48
  • I just don't know what to tell you. I just created a fresh project and copied exactly the code above, into it. Stetho works perfectly. Be sure that your manifest uses `MyApplication`. Be sure that you are running the app you think you are running. Log the call to Stetho.initialize. Report back when you figure it out!! – G. Blake Meike Feb 13 '17 at 18:17
  • I was missing this line android:name= "MyApplication" in the manifest file and now it works. Thank you for your help! – J bouse Feb 14 '17 at 16:34