LoginSignup
28
28

More than 5 years have passed since last update.

StethoでSQLite, Preferenceの中を覗く

Last updated at Posted at 2015-03-17

StethoはAndroidアプリケーション用のデバックブリッジ.
Chrome Developer Toolsを使用してChrome Desktop Browserからリモートデバックを実現する.
ネットワークパフォーマンスの解析等を可能にするが, SQLiteやPreferenceの中を覗くこともできる.
今回はStethoを使ってPreferenceを確認してみる.

Stetho公式: http://facebook.github.io/stetho/

転載元:Android: StethoでSQLite, Preferenceの中を覗く

Gradleを編集

Stethoライブラリを導入するために下記をgradleに追加.

dependencies {
    compile 'com.facebook.stetho:stetho:1.0.0'
}

ApplicationクラスのonCreateで下記を実行.

public class MyApplication extends Application {
  public void onCreate() {
    super.onCreate();
    Stetho.initialize(
        Stetho.newInitializerBuilder(this)
            .enableDumpapp(
                Stetho.defaultDumperPluginsProvider(this))
            .enableWebKitInspector(
                Stetho.defaultInspectorModulesProvider(this))
            .build());
    }
}

あとはアプリを実行し, 端末とPCを接続.
PCのChromeブラウザからchrome://inspect/#devicesにアクセスし, デバッグ対象の端末のinspectを選択.
Developer Toolが起動するのでResources>Local Storageからアプリが持つPreferenceを確認・編集することができる.

DevTools

追記

ProguardのShrinkでstethoに必要なクラスが削除されるのを防ぐ必要がある.
https://github.com/facebook/stetho/issues/42

-keep class com.facebook.stetho.** {*;}

以上.

28
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
28
28