Reputation: 4002
I am trying to use Retrofit2 and also Log errors in Full like its done in Retrofit1 using the
.setLogLevel(RestAdapter.LogLevel.FULL)
I'm am facing an error with .client( Okhttp client ); This is my dependencies below:
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'
}
This is my java code:
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);
I'm using Retrofit 2.0.0-beta3 and still having this issue. I can't move forward from here. Any help is appreciated. See image below:
This is my import statements below:
Upvotes: 0
Views: 3087
Reputation: 6857
Its seems your import statement is from okhttp
,
Check out your import:-
must be import okhttp3.OkHttpClient;
or your retrofit import must be wrong.. it must be retrofit2.Retrofit
[EDIT]
Seems there is problem with their beta versions, revert it to the stable version.
Upvotes: 4
Reputation: 6803
Retrofit is no longer in beta for a while now. Use com.squareup.retrofit2:retrofit:2.2.0
instead.
Upvotes: 1