How to Make HTTP Requests With Ktor-Client (Cooler Than Retrofit!) - Android Studio Tutorial

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • 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/...
    💻 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/...
    Subscribe to my newsletter for regular Android, Kotlin & Architecture advice!
    pl-coding.com/...
    Join this channel to get access to perks:
    / @philipplackner
    Get the source code for this video here:
    github.com/phi...
    Regular live codings on Twitch:
    / philipplackner
    Join my Discord server:
    / discord
    Regular programming advice on my Instagram page: / _philipplackner_
    Checkout my GitHub: github.com/phi...
    You like my free content? Here you can buy me a coffee:
    www.buymeacoff...

Комментарии • 107

  • @vengateshm2122
    @vengateshm2122 2 года назад +5

    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.

  • @azamovdev
    @azamovdev Год назад +3

    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

    • @truongxuan8322d
      @truongxuan8322d Год назад +2

      can you give me the names of youtube channels to learn how to build resfull api + kotlin retrofit?

  • @jatinvashisht4293
    @jatinvashisht4293 2 года назад +7

    Thumbnail is lit 🔥

  • @sergeytarasov5041
    @sergeytarasov5041 2 года назад +7

    Phillip, you explain it so easy and good, I am very impressed, thank you.

  • @CarlosSilva-mm8py
    @CarlosSilva-mm8py 2 года назад +28

    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.😆😆😆

  • @kinggeorges625
    @kinggeorges625 2 года назад +3

    Thanks for the video and efforts you are putting to help people you don't even know. Stay blessed

  • @niranz7745
    @niranz7745 2 года назад +1

    Yes! I love Ktor videos. Can't wait for the KMM videos as well. Thank you Philipp

  • @khanzadakashif8248
    @khanzadakashif8248 2 года назад +2

    I can't decide what's more creative,
    Your videos or your thumbnails...😆

  • @re_allyedge
    @re_allyedge 2 года назад +28

    Hey Philipp! Could you make a tutorial about Authentication using both Ktor server and Ktor client?

    • @vengateshm2122
      @vengateshm2122 2 года назад +2

      Yes there are several authentication. We can start with basic and jwt.

    • @vyas8137
      @vyas8137 2 года назад +2

      @@vengateshm2122 bro could you suggest me some good android development resources?

    • @vengateshm2122
      @vengateshm2122 2 года назад +3

      @@vyas8137 Phillip lackner
      Simplified coding
      Coding in flow
      Rahul Pandey
      Slidenerd
      Android developers documentation, especially code labs.

    • @vyas8137
      @vyas8137 2 года назад +1

      @@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.

    • @vengateshm2122
      @vengateshm2122 2 года назад +2

      @@vyas8137 Start with recycler view, activity, fragment, camera, services, content provider. MVP concepts then mvvm

  • @Coldalecs
    @Coldalecs 11 месяцев назад +4

    Very good info! But this is already outdated, for example instead of `install(JsonFeature)` you now have `install(ContentNegotiation){json()}`. Good work, Philipp!

    • @allanaraujo2157
      @allanaraujo2157 7 месяцев назад

      thank you

    • @allanaraujo2157
      @allanaraujo2157 7 месяцев назад +1

      install(ContentNegotiation) {
      json(Json {
      isLenient = true;
      ignoreUnknownKeys = true
      })
      }

  • @mattgraves3709
    @mattgraves3709 2 года назад

    I appreciate that we implement the interface with KTOR.

  • @quantumgaming7
    @quantumgaming7 2 года назад +2

    Retrofit still wins 💕💕

  • @bertafitocasas7791
    @bertafitocasas7791 Год назад +1

    Hi! Thank you very much. You seem to have saved our project :)

  • @sebastianpalm3495
    @sebastianpalm3495 Год назад +1

    Is a really good video sadly a bit outdated because of the changes in Ktor any plans to do another one in the future?

  • @SuessesSumpfhuhn
    @SuessesSumpfhuhn 4 месяца назад

    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?

  • @Ceisluck
    @Ceisluck 2 года назад +1

    Did you mesaure the eficency of this change in terms of speed/size etc or this is another random video in youtube?

  • @TheZukkino
    @TheZukkino Год назад +3

    You might do an update for v 2.x.x cause of many plugin changes.

  • @PritamDas-rj5fk
    @PritamDas-rj5fk 2 года назад +1

    after update the ktor to 2.0 its show error in clint.get
    mismatch
    help??

  • @devOmarAZ
    @devOmarAZ 2 года назад +2

    really what is the difference between java serializable and kotlin serializable ?
    and kotlin serializable vs parcelable?
    java serializable vs kotlin serializable vs parcelable ?

  • @youprimeprime3046
    @youprimeprime3046 2 года назад +2

    can you make more videos related to ktor stuff thanks

  • @siva_subramaniam
    @siva_subramaniam Год назад

    Great content. Thanks Philipp.

  • @raheemadamboev
    @raheemadamboev 2 года назад +2

    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

  • @madalitsophiri3728
    @madalitsophiri3728 2 года назад

    finally a good tutorial on ktor

  • @RoniTadmor
    @RoniTadmor Год назад +1

    Great video :) any chance for an update for varsion 2... ?

  • @nonconsensualopinion
    @nonconsensualopinion 2 года назад

    Another great video. Thanks!

  • @shanahjrsuping7344
    @shanahjrsuping7344 2 года назад +1

    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?

  • @mattgraves3709
    @mattgraves3709 2 года назад

    Great Video!
    Thanks Phillipp

  • @VeronikaDoma-f5y
    @VeronikaDoma-f5y Год назад

    Thank you Philipp!

  • @slayer5171
    @slayer5171 2 года назад

    This is impressive, thanks for sharing.

  • @richardwilkinson7873
    @richardwilkinson7873 2 года назад

    Once again awesome video :) Is there another video to explain how to consolidate input fields into json and POST??

  • @coldwolf5050
    @coldwolf5050 2 года назад

    Good video, did not know ktor can be used in Android as well.

  • @aabhishek4911
    @aabhishek4911 2 года назад +1

    Btw retrofit can be used for any java/kotlin project , not just android

  • @ekhiw
    @ekhiw 2 года назад +1

    How to make stream data for download large file using ktor?
    Or make a multipart post request for upload large file?

  • @alij3fer
    @alij3fer 2 года назад

    🔥😍 Thanks bro

  • @sebastianpalm3495
    @sebastianpalm3495 Год назад

    Great video as always I have one question how do you configure the client to accept self signed certificates?

  • @Somerandomnessvvv
    @Somerandomnessvvv 2 года назад +2

    Is this also applicable when using ktor websockets?

  • @muhammadhassaansiddiqi8586
    @muhammadhassaansiddiqi8586 2 года назад +1

    please make video for c.Arci + KTOR with Full Error handling. both get and post apis. please
    di how we use in ktor

  • @rivaldohadiwinata6803
    @rivaldohadiwinata6803 Год назад

    very helpful !

  • @MtaufiqH731
    @MtaufiqH731 2 года назад +1

    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.?

    • @PhilippLackner
      @PhilippLackner  2 года назад +1

      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

  • @storypur
    @storypur 2 года назад

    Is ktor good for making large-scale android applications?

  • @nabazbarzanji3221
    @nabazbarzanji3221 2 года назад

    That's awesome💯

  • @japneetraina8146
    @japneetraina8146 Год назад

    ha shilli waa philipp lakdi walli

  • @emmanuelmtera5936
    @emmanuelmtera5936 2 года назад

    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.

  • @ashutoshandhare7626
    @ashutoshandhare7626 2 года назад

    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?

  • @sanjaybhatikar
    @sanjaybhatikar Год назад

    Cool! How to make an OAuth call and stash a JWT token to send with requests? Cheers!

  • @fnax
    @fnax 2 года назад

    Very good video and library! Can it be used for xml apis ?

  • @marlonlom
    @marlonlom Год назад

    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 :)

  • @andreypoltev
    @andreypoltev Год назад

    But how do I refresh it with click of a button, though?

  • @fensom80
    @fensom80 2 года назад

    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!!!!!

  • @PritamDas-rj5fk
    @PritamDas-rj5fk 2 года назад

    can i create a data class with only my nessary variable
    like can i create data class without body and user id

  • @user-kq8yo1qu7m
    @user-kq8yo1qu7m 2 года назад

    Great!!!

  • @Muhfara
    @Muhfara 2 года назад

    please make a coin tutorial and your feedback about coins compared to dagger hilt

  • @myrzabekylychev5112
    @myrzabekylychev5112 2 года назад

    Nice! Thank you! Can you provide video with uploading image to server using multipart form data, please?

    • @vengateshm2122
      @vengateshm2122 2 года назад +1

      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.

  • @veygard
    @veygard 2 года назад

    ty for video

  • @SaherAlSous-welcomes-you
    @SaherAlSous-welcomes-you 2 года назад

    thank you

  • @ymusclecode
    @ymusclecode 2 года назад

    I have 2 emulators, on android 11 does not work, on android 8 works as expected

  • @vedx
    @vedx 2 года назад +1

    Cool 😘

  • @priyaranjanmantri9332
    @priyaranjanmantri9332 2 года назад

    Hey it's awesome...

  • @BearkFearGamer
    @BearkFearGamer 2 года назад

    Better than retrofit!

  • @mehranj73
    @mehranj73 2 года назад +1

    I think Ktor-Client is also suitable for compose desktop.

    • @PhilippLackner
      @PhilippLackner  2 года назад +2

      Sure since it's a kotlin library

    • @maskedredstonerproz
      @maskedredstonerproz 2 года назад +1

      Speaking of compose desktop, Philipp are you ever gonna take a look at that and show us a few things about it???

    • @mehranj73
      @mehranj73 2 года назад

      @@maskedredstonerproz too soon

    • @maskedredstonerproz
      @maskedredstonerproz 2 года назад

      @@mehranj73 what do you mean too soon??

    • @mehranj73
      @mehranj73 2 года назад

      @@maskedredstonerproz It is not production ready and you can also try it in IntelliJ. Compose desktop in still jetpack compose.

  • @vyas8137
    @vyas8137 2 года назад

    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.

    • @cleancodez
      @cleancodez 2 года назад +1

      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

    • @vyas8137
      @vyas8137 2 года назад

      @@cleancodez will check, thanks mate : )

  • @abhijith_mogaveera
    @abhijith_mogaveera 2 года назад

    That means, can we can also use this for interactions with Socket..?

  • @gorkemozgur6796
    @gorkemozgur6796 2 года назад

    I wonder how you can do interceptor like okhttp client

  • @irfanirawansukirman4809
    @irfanirawansukirman4809 2 года назад

    Hi Phillip, how to use Chuck/Chucker using Ktor? thanks

  • @pritamdas1156
    @pritamdas1156 2 года назад

    how to make request with Credentials

  • @alleaffen1926
    @alleaffen1926 2 года назад

    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 :)

    • @vinayparmar7361
      @vinayparmar7361 Год назад

      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?

    • @alleaffen1926
      @alleaffen1926 Год назад

      @@vinayparmar7361 sorry, no not yet.. Hadn't much time to try it. Did you success in the meantime?

    • @alleaffen1926
      @alleaffen1926 Год назад

      @@vinayparmar7361 I think the solution is saving the received token with shared preferences and then add the token with the @Header annotation..

    • @TheZaurHasanov
      @TheZaurHasanov 2 месяца назад

      ​ @vinayparmar7361 did you guys find the way?

  • @thkorkem
    @thkorkem 2 года назад

    Nice video. However, Retrofit is much simpler and useful than that.

  • @subyk6046
    @subyk6046 Год назад

    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. :)

  • @suneelkumar-hm4kd
    @suneelkumar-hm4kd 2 года назад

    10:31

  • @mohamadrezazandieh3003
    @mohamadrezazandieh3003 10 месяцев назад

    awli bood haji

  • @ChristiaanHunter
    @ChristiaanHunter 6 месяцев назад

    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

  • @mrwhoknows
    @mrwhoknows 2 года назад

    0th

  • @TreudtLP
    @TreudtLP Год назад

    Mega scheiße das Video, absoluter Müll die Hälfte des Screens nicht einzublenden

  • @Joe-pz4ss
    @Joe-pz4ss Год назад +1

    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"

    • @flychee123
      @flychee123 Год назад +1

      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
      })
      }

  • @Another0neTime
    @Another0neTime 2 года назад

    Great work! Bravo.