The Ultimate Dagger-Hilt Guide (Dependency Injection) - Android Studio Tutorial

Поділитися
Вставка
  • Опубліковано 21 гру 2024

КОМЕНТАРІ •

  • @leonardosibela
    @leonardosibela 2 роки тому +161

    Man, first of all, you are THE BEST Android UA-cam channel in the whole website.
    Second, you are just awesome!! You are a great teacher and a very charismatic human being.
    Last, but not least, I don't know how you don't get tired of making so many great videos.
    You ARE the best!! Thanks for teaching me so much. It's being a pleasure to have your videos as part of my life.

  • @priyanshugupta7904
    @priyanshugupta7904 2 роки тому +8

    I am a student I can't buy u a coffee but I can like and share your video with my friends.
    Amazing Teaching :)

  • @alexeysimchenko7494
    @alexeysimchenko7494 2 роки тому +40

    I use dagger/hilt every day but usually as copy/paste so today I decided to finally get known how it works. Your explanation is the best of several that I saw today!

  • @shashanknanda7299
    @shashanknanda7299 10 місяців тому +3

    This is the most easy to understand explaination that I've ever found on dagger-hilt till now, you explained each topic very consicely yet clearly

  • @henrygalvan9333
    @henrygalvan9333 2 роки тому +2

    broo thank you, "you never actually call these functions, dagger hilt does", cleared up so much for me!

  • @manuelsilveriof
    @manuelsilveriof Рік тому +28

    This is by far the best explanation of Dagger Hilt I have found online. Not even the official Android Developers' UA-cam channels explain it like you do. Thank you so much!!

  • @Shots_by_ranjith
    @Shots_by_ranjith Рік тому +8

    My man teaches me more than what I learnt from a 4 yearbachelor's degree.

    • @technics6215
      @technics6215 Рік тому +2

      This is about a tool / library. Tools and libraries will change over time. Most of the things you learn in school won't change.
      If you are in engineering school you are not there to learn how to make a hole in metal with one particular kind of machine. You don't need a professor fot that. You are there to know why, when and where you have to make that hole.

    • @SumriseHD
      @SumriseHD Рік тому

      ​@@technics6215but that opinion is way too nuanced!

  • @nrg4285
    @nrg4285 9 місяців тому

    I normally blast through these tutorials but this one took a solid 1-2 hours because of coding and note-taking at the same time and there was so much good content. For example it takes 7 individual scrolls to get through the notes top to bottom, that's a lot more than usual

  • @mithunlzmv806
    @mithunlzmv806 4 місяці тому

    This is the recommended video for learning Dagger Hilt for Android. You don't need to watch anything else. Thanks, Lackner.

  • @osisuper98
    @osisuper98 2 роки тому +3

    I am lost for words already. Man is always hitting the nail on the end. Much love ❤️.

  • @daniellubenov827
    @daniellubenov827 2 роки тому +1

    Those videos are with the latest and the best practices. Really the best android tutorials out there.

  • @VinothKumar-oo8ye
    @VinothKumar-oo8ye Рік тому

    philip lackner, i studied your and workout your Weather app (clean code architecture) course, and i don't understand most of things, then after watching this dependency injection i understand all the doubts i have on the weather app course. super tutorial ;)

  • @khalidrinaldy3671
    @khalidrinaldy3671 Рік тому

    you are the best Kotlin Android Developer's teacher, or maybe the best programming teacher i've ever watched

  • @parulsinghal2k5
    @parulsinghal2k5 9 місяців тому

    you slayyyed it!!! 30 minutes video covered almost everything for a person who knew only how to use dagger2 👏

  • @tonyalbanese6446
    @tonyalbanese6446 2 роки тому +6

    I still can't believe how terrific these videos are. You explanations are superb. Thank you so much for taking the time to make this content.

  • @harishodzic3274
    @harishodzic3274 Рік тому +2

    I always try to give credit where credit is deserved. And you my man are pure gold. I just stumbled on your content and I'm happy for that.
    Fast, to the point, full of valuable information. Keep on going this is great. I will subscribe, upvote, like.
    Wish you a good luck in the upcoming days!

  • @mandarpawar1423
    @mandarpawar1423 2 роки тому

    Man, you don't know how grateful I am right now! THANK YOU SO MUCH!!!

  • @attilabacsa2808
    @attilabacsa2808 2 роки тому +8

    Thank you, excellent content as always. When I decided to switch carrier and become an Android dev, your channel was one of the main sources to learn the basics.
    Keep up the good work! 💯

  • @muyassarabdullah1504
    @muyassarabdullah1504 11 місяців тому

    I always go back to your tutorial because it is very simple and easy to understands from fundamentals point of view

  • @rajm2671
    @rajm2671 Рік тому

    Finallyyy, I learned Dagger-Hilt. Good explanation. Thanks, Philipp

  • @gugan9977
    @gugan9977 2 місяці тому

    This is seriously the best ever video that I watched for learning this concept..I am newbie and learned with comparing the code developed by my company and seriously you are the best🤩

  • @mohinithakkar2172
    @mohinithakkar2172 2 роки тому +2

    Thank you so much for this! It has covered almost all the features of Dagger Hilt.

  • @LinaSarkar7307
    @LinaSarkar7307 2 роки тому

    its priceless. the slickness and the passion of the devs. priceless. what is cheaper and better than soft? Piracy is NOT the answer if you

  • @GoceAnastasovski
    @GoceAnastasovski 2 роки тому +1

    Great video! I finally understood Hilt! I would create a sequel to this video where you focus on unit tests, you write the tests without hilt first and then with Hilt

    • @PhilippLackner
      @PhilippLackner  2 роки тому +1

      I do have a hilt testing video on my channel :)

  • @arma6363
    @arma6363 Рік тому +1

    Hilt would be super easy by your teaching, Thanks alot dear philip

  • @fsfaysalcse
    @fsfaysalcse 2 роки тому +2

    Sometimes I thought you might be a superhero 😜 And you Come from a different universe. Best of luck, brother. I am your biggest fan from Coroutines video playlist ❤

  • @samasama3482
    @samasama3482 11 місяців тому

    The perfect explanation of Dagger Hilt I have ever seen! thank you

  • @jagat.jeeban
    @jagat.jeeban 2 роки тому +2

    You're a great teacher. Hats off to you man!! 🙌 Keep making such types of tutorials on android topics.

  • @moforemmanuel158
    @moforemmanuel158 2 роки тому +1

    your tutorials are the best because you take time to explain the subtle concepts behind the code which is rare from other tutorials
    i just had to watch this once the get the whole scope of what DI with Hilt is and it implementations

  • @mithilmehta1501
    @mithilmehta1501 2 роки тому +13

    Hey Philipp, I am from India and I really love your videos and it helps a lot. Thanks! God bless you and keep up the good work. Your explanation are so simple that even a fresher can understand. 😊

    • @RaajKanchan
      @RaajKanchan 2 роки тому

      Hey Mithil, I am new to Dagger Hilt. Can you help me, I want to pass String value from Activity to an AppModule. How can I do that?

    • @mithilmehta1501
      @mithilmehta1501 2 роки тому

      @@RaajKanchan why do you want to pass string to app module from activity? Do you want to pass it to next activity?

    • @RaajKanchan
      @RaajKanchan 2 роки тому

      ​@@mithilmehta1501 No, no its just an example. Let me give you the example.
      -----------------------------------------------------
      class Customer @Inject constructor(@CName val customerName: String, private val age: Int) {
      fun printCustomerDetails() {
      println("$TAG :: $customerName is $age old")
      }
      }
      @Module
      @InstallIn(SingletonComponent::class)
      object AppModule {
      @Provides
      @Singleton
      @CName
      fun provideCustomerName() = "Mithil Mehta"
      @Provides
      @Singleton
      fun provideCustomerAge() = 24
      }
      @Qualifier
      @Retention(AnnotationRetention.BINARY)
      annotation class CName
      @Inject
      lateinit var customer: Customer
      customer.printCustomerDetails()
      -----------------------------------------
      Here in the module I am providing CustomerName and CustomerAge statically. Not dynamically. I just want to learn how can I do that.

    • @mithilmehta1501
      @mithilmehta1501 2 роки тому +1

      @@RaajKanchan bro, you are getting it wrong. This is not something to be passed usong dagger. This data which should be passed either from activity to another Activity or else load from network for that particular screen. Dagger should be used to inject those dependencies which screen requires but doesn't care how it is created. So, as per my understanding your usecase is incorrect.

  • @sumonchatterjee5337
    @sumonchatterjee5337 4 місяці тому

    Hey, I have recently started watching your channel and I am really impressed by the way of teaching. The explanations are the best. Thankyou for making this videos.

  • @bashi80314
    @bashi80314 2 місяці тому

    Thanks a lot for clearing out lot of questions I had on dagger hilt. Cheers...

  • @pablocruz1302
    @pablocruz1302 2 роки тому +1

    You are the Best Android development content out there. Thanks for your great content

  • @sorousheskandary-l7q
    @sorousheskandary-l7q Місяць тому

    Your videos are amazing especially for some like me that live in country with short resources.

  • @maryfrancegonzales9570
    @maryfrancegonzales9570 2 роки тому

    The KING is BACK! Thanks bro!

  • @mymobile550
    @mymobile550 2 роки тому

    Became so curious after watching this tutorial . Just after I implemented this in
    one of my project including database module.

  • @kamertonaudiophileplayer847
    @kamertonaudiophileplayer847 2 роки тому

    A very frequently my class functionality requires the context. But it is available only in an activity. So I was really frustrated until watched you video. Now, I just tell - inject! That's it, simple and elegant.

  • @nantiyachomtee2998
    @nantiyachomtee2998 2 роки тому

    The quality of your content is incredibly high, awesome stuff!! Thanks a lot!!

  • @7xFuryPlayz
    @7xFuryPlayz Рік тому

    now i understand how to use Hilt properly , within my project but i have still some doubts within my mind about clean architecture implementation, hope so i will figure them too . but thanks for this complete video . 🤩☺

  • @codingwithtd5196
    @codingwithtd5196 Рік тому

    Thanks man. This is one of the best Dagger Hilt tutorials I found.

  • @fredericoamigo
    @fredericoamigo 8 місяців тому

    I’m so grateful for all of your brilliant videos on Android development in kotlin and jetpack compose.
    Thank you so much for this!
    If I might suggest a future video: how to use foreground location for in a MVVP app using datasource-repository-viewmodel architecture.

  • @tasmanlg
    @tasmanlg Рік тому

    I have such praise for your content. Thank you so much, truly.

  • @guitarcat01
    @guitarcat01 2 роки тому +2

    You always teach in a very patient and simple way and all i can do i really thank you SO MUCH for what you're doing! I'd say more than 60% of what i know about android comes from you. This is by far the greatest android development channel on UA-cam =)
    PS: After this video i already implemented Dagger in two of my projects

  • @gastonsaillen
    @gastonsaillen Рік тому +1

    I think we should use @InstallIn(ViewModelComponent::class.java) since the repository lives inside a ViewModel, in the meantime that we inject the repository inside the ViewModel, hilt will then delete this repository instance when the ViewModel is cleared (onCleared is called, ViewModel is destroyed because its activity/fragment does not need it anymore). If we do it with the SingletonComponent it will be tied up with the Application class you created, and hence, the repository instance will outlive the ViewModel.
    Another way of not using @Named could be to use @Qualifiers which can be more verbose on for example creating two different okHttp clients
    Great video Philipp, it contains a lot of excellent suggestions !

  • @manishpingale6558
    @manishpingale6558 2 роки тому

    I understood hilt like never before 🤯

  • @AliAhmad-dev
    @AliAhmad-dev 7 місяців тому

    Thanks a lot, I now can understand DI really well.

  • @azamovdev
    @azamovdev Рік тому

    this cool . I had the same problem and solved it with your content. good luck with your work.

  • @winsonmac
    @winsonmac 2 роки тому +4

    Great sharing! I learned new things from you like @Binds and Lazy Injection

  • @musfickjamil2831
    @musfickjamil2831 2 роки тому

    Philipp you look so fresh in new setup..setup looks awesome. we want setup tour

  • @AnjuMohanan-t9y
    @AnjuMohanan-t9y Рік тому

    Best Video in short time. Good content.

  • @genctasbasi
    @genctasbasi Рік тому

    This guy is a gem.

  • @senk0n
    @senk0n 2 роки тому

    Oh my, thanks to YOU, it's such an easy to understand and implement simple clean arch project for my CV now

  • @masmmaw
    @masmmaw 2 роки тому +1

    love it 💖 still provide complete information and of course free. Thank you.

  • @TerminalKid
    @TerminalKid Рік тому

    dude you're Epic, learning a 'lot of good practices from you which saves me time. 👍👍

  • @realurah
    @realurah Рік тому +1

    damn... you are such a good teacher man

  • @avinashreddy9565
    @avinashreddy9565 Рік тому

    Great Explanation!!! Very Easy to understand...

  • @pqsk
    @pqsk 2 роки тому

    Great video! Thanks so much for the explanation of this library.

  • @Sarthakz99
    @Sarthakz99 2 роки тому

    I was looking for the same Auth token use case!! Thanks a lot!!

  • @Chekist2008
    @Chekist2008 21 день тому

    Simply the best! Thank u and please keep it up

  • @luckydevil1601
    @luckydevil1601 Рік тому

    thank you so much! finally I understood the magic behind this!

  • @PamontBahktar
    @PamontBahktar Рік тому

    You're awesome Philipp, thanks so much for this it's really helpful.

  • @leonkennedy1267
    @leonkennedy1267 8 місяців тому

    Thanks for your videos! It's very helpful! More power to you!

  • @ashishgautam2842
    @ashishgautam2842 2 роки тому

    bro as i'm seeing my growth, i have seen growth in you too..actually / definitely your ahead me but somewhere i feelled sync between us.

  • @abhishekpathak7698
    @abhishekpathak7698 Рік тому

    Indeed it was helpful. But i got confused in appcontainer and module of the app components that are created within the appcontainer

  • @rahulrvp
    @rahulrvp 11 місяців тому

    Thanks a lot for making this video. Super helpful!

  • @Langi667
    @Langi667 Рік тому

    Your tutorials are extremely helpful, thank you so much!

  • @lioliknumberone1428
    @lioliknumberone1428 Рік тому

    very interesting and clear tutorial! Thank you very much!

  • @toniwincent6653
    @toniwincent6653 2 роки тому

    You are the best at explaining this so that I understand! Thank you so much! When I get my first job as a developer I will buy you coffey! 🙂

  • @omkarkshirsagar8812
    @omkarkshirsagar8812 7 місяців тому

    first time i saw video i dont get it , after seeing video second time now its crystal clear

  • @Alchemist10241
    @Alchemist10241 2 роки тому

    This video was the exact info that i have needed.

  • @ankitverma3932
    @ankitverma3932 2 роки тому

    Please also include the use of entry point. How to use injected classes in attachBaseContext of application or activity ?

  • @Dineshkumar-f1f6o
    @Dineshkumar-f1f6o 11 місяців тому

    Thank you so much for your excellent explanation dude
    😀😃😄😁

  • @Hoseinsadonasl-jo4dm
    @Hoseinsadonasl-jo4dm 7 місяців тому

    Really awsome Philipp

  • @BilalBerek-tl3tq
    @BilalBerek-tl3tq 10 місяців тому

    perfectly explained dude.

  • @andinaevitha6950
    @andinaevitha6950 2 роки тому

    ITS REALLY WORKED LOL THANK YOU DUDE

  • @John-qt6qk
    @John-qt6qk 2 роки тому

    Thank you mate, what about a hide and show floatin btn?

  • @giaahayes
    @giaahayes 3 місяці тому

    Great content! Very helpful!

  • @behnawm
    @behnawm 2 роки тому +1

    Thanks for the great video! Please consider explaining different scopes and lifecycles for the dependencies too.

  • @MrVipulLal
    @MrVipulLal Рік тому

    Your videos are all amazing 🙏👍👍👌💯

  • @AK2000YY
    @AK2000YY 4 місяці тому

    thank you bro
    can you speak a lot of Component and scope with example??

  • @ubersticks
    @ubersticks 2 роки тому +1

    Great job Phillip! When should we use "vm = hiltViewModel()" vs "vm:MyViewModel" by viewModels()" ??

  • @MohsenMashkour
    @MohsenMashkour Рік тому

    what we should learn first? MVVM or dependency injection?

  • @chrisperey561
    @chrisperey561 2 роки тому

    you are literally the best

  • @abacaabaca8131
    @abacaabaca8131 7 місяців тому

    The purpose of Dependency Injection is that you can share the same reference to an object even when the objects that wants to share it have different lifetime.
    For example, if I have 3 classes namely `Time`, `A`, and `B`.
    let say Time class is used for benchmarking or profiling your program. It can be used to detect how much time each functions/methods are executed at runtime.
    This means you need to create one single instance of Time class so that A and B can refer to this object. Because, if you create two different objects for A and B , maybe the timing is not continuous and so give wrong result.
    When you have dependency Injection, you have other class that kind of manage the creation of object and it's lifetime. Meaning, if A and B lives in different lifetime, they still be able to share the same reference to Time instance object.
    For example, if A is created first, then the dependency Injection will also create Time object. After A is deallocated, the dependency Injection will save the state of this Time object that have some state profiling instance of A. Then Time will get deallocated.
    Then when B is created, the dependency Injection will create the same object of Time with the same last state for A. Meaning as if Time object is reborn again but with the same state when it was when A is about to die.

  • @muhammadsarimmehdi
    @muhammadsarimmehdi 2 роки тому +1

    can you create a dagger-hilt tutorial with custom scopes? That will be very useful to understand, especially for apps with user logins

  • @kamrulhuqmaroof113
    @kamrulhuqmaroof113 2 роки тому

    Wow man it really works!

  • @theevan3867
    @theevan3867 2 роки тому +1

    Thanks Phillip! if you can, can you make a youtube short of app examples that would be considered impressive to get an entry level position? Please. Thanks!!!

  • @RockRider2k
    @RockRider2k 2 роки тому +1

    Imho the overhead of marking every here and there with annotations worth it only in huge projects. So the benefits of using dagger are very subjective

    • @kvasir25
      @kvasir25 Рік тому

      Also this makes all the configuration being spread across multiple files which imho makes it more complex than it's needs to be

  • @shootsir
    @shootsir Рік тому

    29:56 what does it mean "you should always use interface abstraction" ?

  • @ultron1060
    @ultron1060 8 місяців тому

    hi,I was wondering which shortcut he is using to create bring create new file Gui at 9:15

  • @SapphireStudioart
    @SapphireStudioart Рік тому

    Great video! Well explained, thank you

  • @hibroonyancha
    @hibroonyancha 11 місяців тому

    I love the videos straight forward Explanation but my app keeps crushing when implementing the hilt viewmodel ,with an error of you cannot access the NavBackStackEntry's viewmodels after the navback stack entry is destroyed. Please someone help

  • @dawidtyburek
    @dawidtyburek 2 роки тому +7

    Love it! Great that you are using Binds for interfaces/abstracts, most guides I have seen is just showing Provides but imho Binds is as much important😊

    • @PhilippLackner
      @PhilippLackner  2 роки тому +3

      💪💪

    • @remmievail2003
      @remmievail2003 2 роки тому +1

      Philipp makes the comment that Bind generates less code, is that the only difference? @Binds and @Provides seem to be basically the same thing, just slightly different.

    • @ChrisAthanas
      @ChrisAthanas 2 роки тому

      @@remmievail2003 one is concrete implementation of a particular type, one is for a mapping an interface to a particular implementation of a type

  • @rizfirsy
    @rizfirsy Рік тому

    Can we use ksp instead of kapt when using dagger-hilt? 8:43

  • @chitye-aung
    @chitye-aung 2 роки тому

    Awesome! Thank You Philip

  • @iziaulla
    @iziaulla Рік тому

    Great video man!!! I have just one question though. Where is all the Api parsing done? I thought it was in the view model. An object of the ViewModel is created in MainActivity. Then the UI is assigned its values in the MainActivity, correct?

  • @whogashaga666
    @whogashaga666 2 роки тому

    Thanks for sharing this video.

  • @atelier_mongame4119
    @atelier_mongame4119 2 роки тому

    This was so helpful!! Thank you

  • @sergioqcostas
    @sergioqcostas Рік тому

    How can I provide the viewModel in a singleton declared in the AppModule?

  • @bdjobstv8575
    @bdjobstv8575 2 роки тому

    thanks a lot!!! so nice reverb