Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix: "Unresolved reference: buffer" or "Using 'buffer(Source): BufferedSource' is an error. moved to extension function"?

Tags:

android

okio

I had 3 line code to get body from OkHttp3 source:

val responseBody = response.peekBody(response.body()!!.contentLength())
val source = GzipSource(responseBody.source())
val body = Okio.buffer(source).readUtf8() //issue is that line

on another computer I get error: "Using 'buffer(Source): BufferedSource' is an error. moved to extension function"

So fix it by replacing last line by:

val body = source.buffer().readUtf8()

bun now on the fist computer I have error: "Unresolved reference: buffer" so I need to revert that change.

What is wrong? base on error message I cannot figure out. It seems that it's issue with gradle configuration. But what? How to have compiling code on both computers.

like image 972
LunaVulpo Avatar asked Jul 30 '19 06:07

LunaVulpo


1 Answers

add implementation "com.squareup.okio:okio:2.3.0" to your build.gradle

like image 82
MikeRzDev Avatar answered Oct 02 '22 05:10

MikeRzDev