I am working on an android app using Dagger2 + Retrofit + RxAndroid + OkHttp3 + New architecture components. Min sdk = 16.
Issue : When running the app on API 16, the Url generation is not correct. Url is missing the @QueryMap parameters I am passing via Retrofit. The same is working fine when I am testing the app on api levels 21+.
Correct url - on api 21+ - "http://api.apixu.com/v1/forecast.json?q=IDR&days=10&key=apikey"
url generated on api 16/19 - "http://api.apixu.com/v1/forecast.json"
Retrofit Interface -
@GET("forecast.json")
fun fetchWeatherDetails(
@QueryMap hashMap: @NotNull HashMap<String, String>
): @NotNull Observable<ApiResponse>
Retrofit Builder -
val httpClient = getOkHttpClient()
return Retrofit.Builder()
.baseUrl(apiBaseUrl)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(httpClient)
.build()
OkHttpClient -
val builder = OkHttpClient.Builder()
builder
.cache(cache)
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.followRedirects(true)
.followSslRedirects(true)
val httpLoggingInterceptor = HttpLoggingInterceptor()
if (BuildConfig.DEBUG) {
httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
} else {
httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.NONE
}
builder.addInterceptor(HeaderInterceptor())
.addInterceptor(httpLoggingInterceptor)
return builder.build()
Its been more than 2 days since I am stuck in this issue. Any help would be appreciated.
Update : Api query Code is working fine on API 21+.
Failed on API-16 & API-19.