【发布时间】:2017-03-08 17:16:34
【问题描述】:
我正在尝试使用 Retrofit2 并在 Full 中记录错误,就像在 Retrofit1 中使用
.setLogLevel(RestAdapter.LogLevel.FULL)
我在使用 .client(Okhttp 客户端)时遇到错误;这是我的依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5'
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
}
这是我的java代码:
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Api.BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build();
Interface service = retrofit.create(Interface.class);
我正在使用 Retrofit 2.0.0-beta3 并且仍然遇到此问题。我不能从这里继续前进。任何帮助表示赞赏。见下图:
这是我下面的导入语句:
【问题讨论】:
-
使用稳定版改造
标签: android retrofit okhttp okhttp3