I used Retrofit library in my android application. My project's minSDK is 16. Now I see that my apps not working on SDK < 21 because of retrofit version. My retrofit version:
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
I tested OkHttp 2 but it is not adapted with my retrofit. What should I do?
The problem is that OkHttp3, from version 3.13.0 upped its minimum SDK version to API 21+.
If you just want to do basic HTTP(s) requests and do not care about TLS 1.2, then you can just exclude that specific version and use 3.12.13 which is the last version to support minSDK 9+.
implementation("com.squareup.retrofit2:retrofit:2.9.0") {
exclude group: "com.squareup.okhttp3"
}
implementation "com.squareup.okhttp3:okhttp:3.12.13"
Add this to your build.gradle file and things should start working. However, from the next version, you should ideally be removing this and up your minSDK level to 21+.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With