Hi guys, Has anybody else troubles trying to inclu...
# ktor
r
Hi guys, Has anybody else troubles trying to include the "io.ktorktor client okhttp2.0.0-beta-1" dependency? It just could not resolve although I've included google an maven Central repository
a
Please try to add
-jvm
suffix so it will look like
io.ktor:ktor-client-okhttp-jvm:2.0.0-beta-1
. Does it work after this change?
r
i´m afraid no. it´s still: Could not resolve io.ktorktor client okhttp jvm2.0.0-beta-1.
a
That's strange. It works on my machine with and without that suffix.
r
mmm
m
I can't even get it to resolve io.ktorktor client okhttp1.6.7 Same thing? I don't know, but it's preventing my builds 😞
r
do you try to download right no?
or do you have it cached?
m
Errr, pardon? It can't find it. Surely the build should find it if it's local?
r
other dependencies are working, like "io.ktorktor client android2.0.0-beta-1"
but no this one
if you have cached the dependency, and you work offline, you should compile
but, for me, I can´t download it
m
The problem survives a "clear caches", so it's a failure to download for me too.
a
What error did you get from Gradle?
r
Could not resolve io.ktorktor client okhttp jvm2.0.0-beta-1.
a
Usually, there are also more descriptive error messages.
r
it´s like the repository doesn´t provide the artifactory
image.png
a
What if you click on the top entry?
r
nothing
even i´ve got Build Successful
but, in the code, I can´t import and use the classes
a
So your project compiles fine?
And you can run it?
r
yes, it compile, and i can run, but I can´t use that dependency
a
Please share your code snippet
r
which one?
a
Where you try to use OkHttp
r
the gradle file?
m
Here, the import has been marked as a failure for a long time, but it's just recent that it now won't build. I'm using OkHttp in a commonMain .kt file
a
No, your application code
r
I´ve just copy the code from here:
import io.ktor.client.engine.okhttp.*
val client = HttpClient(OkHttp)
this is not working
if i included this code, I can´t compile
a
@Rover Sanchez is your project multiplatform?
r
yes
I´ve included this dependency in the shared buuild.gradle
a
For the jvmMain sourceset, right?
r
mm, no
a
OkHttp engine is JVM only
🙏 1
🙄 1
r
for the commonMain
ohh, fuck
that´s a good explanation
sorry man, that´s my fault
@Aleksei Tirman [JB], do you know if there is another way to include interceptors? for ios an android at least
a
Yes, you can add interceptors for the Ktor client
r
do you have a link or some example?
I´ve seen that for OkHTTP
a
There is not much information in the documentation about this topic. What do you need to implement?
r
it´s just a poc right now
i want to know hoy i should do it
I´ve seen how to add Authentication
but, I want to know if there is a way of do whatever
like we ususally do with okhttp
a
For example, that's how you can add a custom header for every request:
Copy code
val client = HttpClient()
client.requestPipeline.intercept(HttpRequestPipeline.Render) {
    context.header("custom", "123")
}
r
mm, nice
it´s good to know
a
Also, there are
client.receivePipeline
and
client.sendPipeline
r
I think for now it´s enough
thanks a lot for your help @Aleksei Tirman [JB]