Hi, I am implementing amazonaws live streaming, I tried to add dependency on my project, but is showing error on OkHttpClient.
0
Hi, I added amazonaws ivs library, after i added this library I am getting this error on this Lokhttp3/OkHttpClient$Builder.
Below library added on app level build.gradle // Retrofit implementation 'com.squareup.retrofit2:retrofit:2.9.0' implementation 'com.squareup.retrofit2:converter-gson:2.9.0' implementation 'com.squareup.okhttp3:okhttp:4.10.0' implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0' implementation 'com.amazonaws:ivs-broadcast:1.9.0:stages@aar'
ApiClient.java public class ApiClient {
private static Retrofit retrofit = null;
private static Retrofit uploadRetrofit = null;
private static final int HTTP_TIMEOUT_MS = 10000;
public static ApiInterface getWebService() { return getClient().create(ApiInterface.class); }
public static Retrofit getClient() {
if (retrofit == null) {
/* HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
logging.level(HttpLoggingInterceptor.Level.BODY);*/
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(HTTP_TIMEOUT_MS, TimeUnit.MILLISECONDS)
.readTimeout(3, TimeUnit.MINUTES)
.writeTimeout(3, TimeUnit.MINUTES)
.addNetworkInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = null;
Request original = chain.request();
// Request customization: add request headers
Log.d("", "intercept: "+ com.app.chobi.model.GetSet.getAuthToken());
Log.d("", "intercept: "+GetSet.getUserId());
Request.Builder requestBuilder = original.newBuilder()
.addHeader(com.app.chobi.utils.Constants.TAG_AUTHORIZATION,
com.app.chobi.model.GetSet.getAuthToken() != null ? com.app.chobi.model.GetSet.getAuthToken() : "")
.addHeader("Connection", "close").
addHeader(com.app.chobi.utils.Constants.TAG_USER_ID, GetSet.getUserId() != null ? GetSet.getUserId() : "");
request = requestBuilder.build();
return chain.proceed(request);
}
})
.build();
retrofit = new Retrofit.Builder()
.baseUrl(Constants.API_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
// .addConverterFactory(ScalarsConverterFactory.create())
.build();
}
return retrofit;
}
public static Retrofit getUploadClient() {
if (uploadRetrofit == null) {
OkHttpClient httpClient = new OkHttpClient.Builder()
.callTimeout(60, TimeUnit.MINUTES)
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(3, TimeUnit.MINUTES)
.writeTimeout(3, TimeUnit.MINUTES).build();
uploadRetrofit = new Retrofit.Builder()
.client(httpClient)
.baseUrl(Constants.API_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return uploadRetrofit;
}
}
已提問 1 年前檢視次數 81 次lg...
沒有答案
- 最新
- 最多得票
- 最多評論
相關內容
- 已提問 1 年前lg...
- 已提問 10 個月前lg...
- 已提問 4 個月前lg...
- AWS 官方已更新 7 個月前
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 1 年前