2016-05-19 3 views
2

私はAndroidのエミュレータ(Genymotion)のアプリを開始しました。問題はChrome Dev Toolsで何も調べられないことです(下記のスクリーンショットを参照)。任意のヒント ?ネットワーク検査用にstethoをokhttp3で使用する方法は?

Stetho

これはクローム クロームでこのURLを入力した後、私が見たものである

(アドレスバー)で

Google Chromeの開発ツール:///

Chrome Dev Tools

TrainerWorkoutApplicationを検査.java

import android.app.Application; 
import android.content.Context; 

import com.facebook.stetho.Stetho; 

public class TrainerWorkoutApplication extends Application { 
    @Override 
    public void onCreate() { 
     super.onCreate(); 

     Stetho.initialize(Stetho.newInitializerBuilder(this) 
     .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this)) 
     .build()); 
    } // onCreate() 

} // TrainerWorkoutApplication 
この問題を解決するには

LogInActivity.java

package com.trainerworkout.trainerworkout.activity; 

//... 

/** As a personal trainer I need to log in so that I can have access to the app. */ 
public class LogInActivity extends AppCompatActivity { 
    public static OkHttpClient client; 
    private OkHttpClient.Builder builder = new OkHttpClient.Builder(); 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     // ... 
     builder.addInterceptor(new AddCookiesInterceptor(context)); 
     builder.addInterceptor(new ReceivedCookiesInterceptor(context)); 

     builder.addNetworkInterceptor(new StethoInterceptor()); 

     client = builder.build(); 
    } // onCreate() 

    //... 

} // LogInActivity 

build.gradle(アプリ)

apply plugin: 'com.android.application' 

android { 
    //... 
} // android 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.3.0' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'com.squareup.okhttp3:okhttp:3.0.1' 
    compile 'com.google.code.gson:gson:2.5' 
    compile 'com.android.support:design:23.3.0' 
    compile 'com.android.support:support-v4:23.3.0' 
    compile 'de.hdodenhof:circleimageview:2.0.0' 
    compile 'com.facebook.stetho:stetho:1.3.1' 
    compile 'com.facebook.stetho:stetho-okhttp3:1.3.1' 
} // dependencies 

答えて

0

は、私は、Applicationクラスは、アプリケーションパッケージではなく、Javaパッケージにすべきだと思います。また、アプリケーションクラスが、私はこのチュートリアルをお勧めしますStethoの使用方法の詳細について

enter image description here

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

のAndroidManifest.xml

で宣言されていることを確認してください。

Debugging Android Apps with Facebook's Stetho

関連する問題