How to Make HTTP Requests With Ktor-Client (Cooler Than Retrofit!) - Android Studio Tutorial
Вставка
- Опубліковано 1 жов 2021
- Network requests with Ktor? Yes, that's possible! In this video you'll learn how.
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:
pl-coding.com/premium-courses...
💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:
elopage.com/s/philipplackner/...
Subscribe to my newsletter for regular Android, Kotlin & Architecture advice!
pl-coding.com/newsletter
Join this channel to get access to perks:
/ @philipplackner
Get the source code for this video here:
github.com/philipplackner/Kto...
Regular live codings on Twitch:
/ philipplackner
Join my Discord server:
/ discord
Regular programming advice on my Instagram page: / _philipplackner_
Checkout my GitHub: github.com/philipplackner
You like my free content? Here you can buy me a coffee:
www.buymeacoffee.com/philippl...
Yes! I love Ktor videos. Can't wait for the KMM videos as well. Thank you Philipp
Thanks for the video and efforts you are putting to help people you don't even know. Stay blessed
Hey Phillip last week I learnt ktor client for android and I thought you will put a video on that.
Coo I predicted it.
You are better teacher.
I appreciate that we implement the interface with KTOR.
Hi! Thank you very much. You seem to have saved our project :)
I have been using Retrofit2 for a long time, after this video I realized that ktor is very light and easy, thank you very much
can you give me the names of youtube channels to learn how to build resfull api + kotlin retrofit?
Thumbnail is lit 🔥
Phillip, you explain it so easy and good, I am very impressed, thank you.
Thank you!
This is impressive, thanks for sharing.
Great content. Thanks Philipp.
finally a good tutorial on ktor
Another great video. Thanks!
Great work! Bravo.
Thank you Philipp!
Great Video!
Thanks Phillipp
Thanks for watching!
🔥😍 Thanks bro
Once again awesome video :) Is there another video to explain how to consolidate input fields into json and POST??
Hi Phillip, thank you so much for the video. It has opened my eyes quite a a bit as I would like to get into native app development. My question is, would it be possible to use generics for the post service so that the code doesn't need to be copied and pasted so many times?
That's awesome💯
Hey Philipp, thanks for this amazing video! I'd need to know how to send more complex client requests with parameters and basic authentication details to the server. Could you maybe do a second video on this?
Good video, did not know ktor can be used in Android as well.
very helpful !
Retrofit still wins 💕💕
Very good info! But this is already outdated, for example instead of `install(JsonFeature)` you now have `install(ContentNegotiation){json()}`. Good work, Philipp!
thank you
install(ContentNegotiation) {
json(Json {
isLenient = true;
ignoreUnknownKeys = true
})
}
Did you mesaure the eficency of this change in terms of speed/size etc or this is another random video in youtube?
Hey Philipp! Could you make a tutorial about creating your own android library and publishing with the help of jitpack in gradle 7.0 please
Hi Phillip, could you record a video about MVVM + Clean Architecture + FirebaseAuth / FirebaseRealTimeDataBase, I have many doubts about this and I believe it will help not only me but others as well. Great video.😆😆😆
Real-time database is not used anymore. Firestore is the better option
@@user-kd4gl9rf5k why? which is the most used now?
How to make stream data for download large file using ktor?
Or make a multipart post request for upload large file?
Great video as always I have one question how do you configure the client to accept self signed certificates?
Hi Phillip, thank you so much for the video. wanna ask about unit testing ktor client and spi implementation using mocks, the json examples and its usang in unit and integratin tests :)
Hey, how do we use the create post function? Like I've been searching for a whole day now on how to send a post request, but none have shown the way to call the post function from the main_activity.kt file. We created the functions and implementations for post request, but how do we really call that from the main function?
I can't decide what's more creative,
Your videos or your thumbnails...😆
Hey Philipp! Could you make a tutorial about Authentication using both Ktor server and Ktor client?
Yes there are several authentication. We can start with basic and jwt.
@@vengateshm2122 bro could you suggest me some good android development resources?
@@vyas8137 Phillip lackner
Simplified coding
Coding in flow
Rahul Pandey
Slidenerd
Android developers documentation, especially code labs.
@@vengateshm2122 bro could you please provide the links for beginners I just know basic kotlin so what all I should look for as the android development domain is always changing.
@@vyas8137 Start with recycler view, activity, fragment, camera, services, content provider. MVP concepts then mvvm
Is ktor good for making large-scale android applications?
Very good video and library! Can it be used for xml apis ?
ha shilli waa philipp lakdi walli
Hello Philip followed the video in all steps but suddenly i always get 400 error , what step might have i gone wrong? is it the data class maybe or ? versions? Thanks in advance.
really what is the difference between java serializable and kotlin serializable ?
and kotlin serializable vs parcelable?
java serializable vs kotlin serializable vs parcelable ?
Great!!!
Btw retrofit can be used for any java/kotlin project , not just android
Yep but not kmm
after update the ktor to 2.0 its show error in clint.get
mismatch
help??
thank you
Nice! Thank you! Can you provide video with uploading image to server using multipart form data, please?
Hey I would suggest follow ktor doc.
I know Phillip videos are awesome but if you don't try to understand on your own you will end up searching for tutorials all time.
Phillip is investing his valuable time to provide quality content.
Hope he will cover the topic also that you want.
Meanwhile You can look into the docs and give a try.
If you did then go ahead and write an article in medium or dev.to what you learnt.
You will feel confident b that time.
You might do an update for v 2.x.x cause of many plugin changes.
So we use ProduceState is a trick to make an app without viewmodel.? So the data still dynamic and the state is not change if we rotate the phone.?
No don't get this wrong. I just don't used a viewmodel here because the focus is on ktor. Just to get an understanding of how the ktor library works
Great video :) any chance for an update for varsion 2... ?
ty for video
can you make more videos related to ktor stuff thanks
Hey it's awesome...
Is a really good video sadly a bit outdated because of the changes in Ktor any plans to do another one in the future?
can i create a data class with only my nessary variable
like can i create data class without body and user id
Okay, so to put it all together, Kotlin Multiplatform using clean architecture and MVI using Ktor? to call a NodeJS Graphql server
UI will be Jetpack Compose for Android and SwiftUI for Apple products. Can you please make this video or better option. Please? Thankyou!!!!!
please make video for c.Arci + KTOR with Full Error handling. both get and post apis. please
di how we use in ktor
please make a coin tutorial and your feedback about coins compared to dagger hilt
Cool 😘
I wonder how you can do interceptor like okhttp client
Cool! How to make an OAuth call and stash a JWT token to send with requests? Cheers!
Is this also applicable when using ktor websockets?
Yes
But how do I refresh it with click of a button, though?
I have 2 emulators, on android 11 does not work, on android 8 works as expected
That means, can we can also use this for interactions with Socket..?
yes
Hey man! Could you suggest some good resources to learn Android development from beginners to advanced , Cause I tried numerous resources most of them are outdated and some don't work properly.
i think is here, i learnt from him since my start, and now i can make apps through his knowledge, Philip this is great.
i also have some conted though my audio is not good, you can check if they might be of help to you.
Just click my profile. but remember, Philip has almost what you need to get started as a pro dev
@@cleancodez will check, thanks mate : )
Better than retrofit!
Hi Phillip, how to use Chuck/Chucker using Ktor? thanks
Did you find that?
I think Ktor-Client is also suitable for compose desktop.
Sure since it's a kotlin library
Speaking of compose desktop, Philipp are you ever gonna take a look at that and show us a few things about it???
@@maskedredstonerproz too soon
@@mehranj73 what do you mean too soon??
@@maskedredstonerproz It is not production ready and you can also try it in IntelliJ. Compose desktop in still jetpack compose.
Hello, I need to use a get-request to get the bearer token and then use this token for another get-request where for the profile-informations. Is this possible with Ktor? I am relatively new on this programming things, so maybe someone could give me some hint/s.. Thanks in advance. And thanks for this clear tutorial, it helped me a lot :)
hey, I am at the situation where you were month ago.. I am having the concern.. can you please recommend the way if you have found the solution?
@@vinayparmar7361 sorry, no not yet.. Hadn't much time to try it. Did you success in the meantime?
@@vinayparmar7361 I think the solution is saving the received token with shared preferences and then add the token with the @Header annotation..
@vinayparmar7361 did you guys find the way?
13:35 isnt better wrap result in repository? In repository I call api.getPost function who will return Result and in VW i can handle onSuccess and onFailure.
Btw thanks a lot for the video. :)
Nice video. However, Retrofit is much simpler and useful than that.
It depends
how to make request with Credentials
10:31
awli bood haji
0th
Mega scheiße das Video, absoluter Müll die Hälfte des Screens nicht einzublenden
hi Mr Lackner, i am still learning but a bit confused with the build.grade.kts, my file looks like this dependencies { implementation(libs.androidx.core.ktx)... your gitHud looks like this dependencies { implementation 'androidx.core:core-ktx:1.6.0'....
I guessing this is a different language format to set the dependencies ?
thanks for your vids
I am getting an Unresolved reference: JsonFeature error. I found one stackoverflow post but it didn't fix my issue. I have the following dependencies:
def ktor_version = "2.2.2"
implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-android:$ktor_version"
implementation("io.ktor:ktor-client-apache:$ktor_version")
implementation("io.ktor:ktor-client-json:$ktor_version")
implementation "io.ktor:ktor-client-serialization:$ktor_version"
implementation "io.ktor:ktor-client-logging:$ktor_version"
implementation "ch.qos.logback:logback-classic:1.4.5"
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0"
works for me with the same dependencies but 2.2.3 and the following code instead of the JsonFeature: install(ContentNegotiation){
json(Json{
prettyPrint = true
isLenient = true
})
}