i'm migrating from okhttp 3.14 to okhttp4, accordings to migration guide, when replacing "response.body()?" call to "response.body?" IDE shows error " Cannot access 'body': it is package-private in 'Response' " at last line of code
val request = Request.Builder().url(url).build()
val response = coreNetwork.getOkHttp().newCall(request).execute()
val stream = response.body?.source()?.inputStream()
if i'm trying "response.body()?" call, shows error " Using 'body(): ResponseBody?' is an error. moved to val " as expected.
Solved, i'm start watching to what version of okhttp linked every import, and one interface linked to okhttp-3.12.0.jar. This interface belongs to separate gradle module, and i found that i forgot add a dependency ' implementation "com.squareup.okhttp3:okhttp:4.2.2" ' to .gradle file of that module. (in that case class should not found okhttp dependency at all, but somehow found old version and depends on it)
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