Dagger-Hilt in Detail - Full Course

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

КОМЕНТАРІ • 171

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

    Over time, a few things changed in regards to dagger hilt. I made a new video in which I cover the most up to date things and also some more concepts I didn't cover in this one:
    ua-cam.com/video/bbMsuI2p1DQ/v-deo.html

  • @fb767
    @fb767 3 роки тому +93

    Also, note that ApplicationComponent has been replaced with SingletonComponent. ApplicationComponent will now cause a unresolved reference error.

    • @vamsireddy7560
      @vamsireddy7560 3 роки тому

      Yes ! ApplicationComponent is Deprecated in new Version of Dagger then we have Instead use SIngletonComponent

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

      thanks

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

      @@vamsireddy7560 but how do you annotate the dependency itself if the class is a singleton and you want it to only exist at activity level?

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

      @@yarivzip I believe that's ActivityComponent

  • @livlop
    @livlop 3 роки тому +15

    This is really a complete video about Dagger Hilt and very easy to understand, as Philipp started to explain "if you want to inject 2 strings", you can realize that this video is better than others on UA-cam and in the same way it has enough fundamentals concepts of Hilt so you can start the implementation in your application.
    Really thanks Sir 🤜🤛

  • @durbie90
    @durbie90 3 роки тому +4

    Please don't ever stop making videos. Every time I watch one of your videos I get an Aha! Moment. Learning so much from you.

  • @mikemikee7797
    @mikemikee7797 3 роки тому +34

    Android file system could be also a good candidate for "in detail" video ^^

  • @aravindhsamidurai5300
    @aravindhsamidurai5300 3 роки тому +11

    This is an awesome video to easily understand Hilt. Even Google developers also don't teach like this. Thanks a lot, @Philipp Lackner for making this video.

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

    I finally understand what is digger hilt after days of research...

  • @mkc0321
    @mkc0321 3 роки тому

    why people dislike such amazing videos ? i think its youtube algorithim which does it automatically

  • @bjugdbjk
    @bjugdbjk 3 роки тому +6

    This video clarified my many questions on Hilt and you have such a great skill of explaining complex things pretty simple way. Thanks again.

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

    I wish every tutorial on UA-cam would be on this level! Too clean.

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

    I've always thought CodingInFlow and CodingWithMitch's tutorials were good, but yours are better.

  • @Another0neTime
    @Another0neTime 3 роки тому +5

    I was just reading a cheat sheet to get familiar with the annotations, then you upload this awesome video. Thanks!!!

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

      Can you please provide me that cheat sheet please 👍

  • @Zeeshan-Syed
    @Zeeshan-Syed 3 роки тому +20

    I actually love to see programming videos get 0 dislikes..

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

    Thank you philip, the annotation @Named one helps me to deal with the problem with multiple BASE URL, Thankkk uuuu

  • @abbasadrali
    @abbasadrali 3 роки тому

    Thankyou Man. Have learn too much in a single video..

  • @farruhhabibullaev5316
    @farruhhabibullaev5316 3 роки тому

    Thanks for brief but complete intro to Hilt.

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

    Thanks for making such clear and elaborative videos. Best

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

    i come back again!! thanks phillipp
    😀Actually , you give me a lot help in Android dev!!

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

    You should be awarded

  • @nevermore7755
    @nevermore7755 3 роки тому +6

    For those having trouble with ViewModel log cat:
    @Module
    @InstallIn(ActivityRetainedComponent ::class)
    object MainModule {
    // This will only live in main activity
    // Cannot have @singleton that only lives as long as our activity
    // Instead of @Singleton, we use activity scoped
    @ActivityRetainedScoped
    @Provides
    @Named("String2")
    // if we need to access context, say strings file, how?
    // We used context as a parameter!!
    // dagger hilt will also figure out which testString1 we will inject!!
    fun provideTestString2(@ApplicationContext context: Context,
    @Named("String1") testString1: String) =
    "${context.getString(R.string.string_to_inject)} - $testString1"
    }

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

      @FightingCold Thanks, This was helpful for me, As I am using hilt dependency version 2.41.

  • @phatho3875
    @phatho3875 3 роки тому

    Nice. What I need is an simple example of DI. And this is exactly what I’m looking for

  • @vipullal7689
    @vipullal7689 3 роки тому

    Couldn't be better explained. Thanks!

  • @mustafaammar551
    @mustafaammar551 3 роки тому +1

    man i need this video so much
    Thank you very much BRO
    wish you all the best❤❤❤👍👍👍

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

    You have gained muscle 💪

  • @yvanndeme3708
    @yvanndeme3708 3 роки тому

    Thank a lot for this Tuto Phillip .

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

    you are a good teacher i love your way of teaching please keep it up and upload more tutorials.

  • @bro_chenzox
    @bro_chenzox 3 роки тому +1

    You use a parameter in ViewModel and scope of that parameter is ActivityScoped but has to be not less than ViewModelScoped. Component of InstallIn has to be the respective ViewModelComponent at least.

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

    for new version use SingletonComponent::class rather than ApplicationComponent::class

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

    Thank you for explaining hilt in details !!!!

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

    Thanks for such a wonderful explanation
    I appreciate your efforts

  • @MunyiriTom
    @MunyiriTom 3 роки тому

    Nice video. The demo and explanation makes it very easy to understand DI in android

  • @GriNAME
    @GriNAME 3 роки тому

    Oh man, it exactly that I was looking for! Thank you so much!

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

    すごく参考になりました。ありがとうございます!

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

    Wish I can like this tutorial more than one time! You saved my days, thank you!

  • @AtLinuxTerminal
    @AtLinuxTerminal 3 роки тому

    COOL ! Thanks for the explaination it's open my mind :) now heading back to Android Studio.

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

    Thank you great explanation 🙏

  • @yashkumar9501
    @yashkumar9501 3 роки тому +1

    Much needed........
    Thank You sir 🙏🙏

  • @SahilGargjava
    @SahilGargjava 3 роки тому

    Who the hell are these 5 people giving dislike to this kind of video. Great job man, keep up the good work

  • @iJuce
    @iJuce 3 роки тому +1

    Hi Philipp, can you make a video about how to read the android developer documentation and learn to help outselves? Love your vids😁

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

      Sounds stupid but by just reading it. There is no "right way"

  • @emmanuelpregnolato5026
    @emmanuelpregnolato5026 3 роки тому

    Tx Phil, nicely done, the pace was perfect.

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

    One more point about Dagger Hilt is that you are not able to configure it for the library project as the entry point for it always has to be the Application which is absent in the library.

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

    Perfect ! Your videos the best ones in all youtube bro!
    Have you got same videos about Koin ?

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

    Great explanation of a very difficult topic

  • @Kunal-jp8tn
    @Kunal-jp8tn 2 роки тому

    Thank you so much for this amazing video.

  • @renardsskutels
    @renardsskutels 3 роки тому +3

    Thank you very much for that!

  • @mohamadrezazandieh3003
    @mohamadrezazandieh3003 3 роки тому

    the best tutorial forever :) thanks, Philipp

  • @c99rahul
    @c99rahul 3 роки тому +3

    You should use the SingletonComponent, as ApplicationComponent doesn't exist in the new Dagger anymore.

  • @hanifalfaqih
    @hanifalfaqih 3 роки тому

    Thank you, it help me to how implement dagger hilt in my project

  • @daniyar2718
    @daniyar2718 3 роки тому

    Thanks, nice constructive explanation👍

  • @taslimoseni2231
    @taslimoseni2231 3 роки тому

    Awesome explanation. Thank you.

  • @Arohap_me
    @Arohap_me 3 роки тому

    thank you, this was a short but useful tutorial

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

    Excellent 👍

  • @abdo-ar-888
    @abdo-ar-888 2 роки тому

    Thanks for your amazing tutorials ❤

  • @amitmondal7427
    @amitmondal7427 3 роки тому

    I really enjoyed the Dagger-Hilt 💕💕💕

  • @ayoubdev
    @ayoubdev 3 роки тому +1

    Hey phillip can you put details video about supporting multiple screen in 2020 I see a lot of tutorial but none of works thanks for great videos

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

    It would be awesome to explain and show things about scoping, regardless this is a good video coming from plain Dagger 2

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

    Philipp looks like a gangsta in the thumbnail 😂❤️

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

    Watching your videos feels like cheating :). Every time I struggle with something I always watch one of your relevant videos, and voila. Thanks a million times and more man...

  • @DaniyalAk
    @DaniyalAk 3 роки тому

    It's helpful and awesome teaching style 👍

  • @yaboyjz
    @yaboyjz 3 роки тому

    very nice video man thank you

  • @i_senne
    @i_senne 3 роки тому

    Great content. Thankssss Philipp

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

    Hey, is providing Glide instance with hilt a good practice too? Because in your spotify clone app you provided an adapter instance as well along with glide instance. Kinda confusing, if I only wanted to pass an arraylist to my adapter but passing the glide instance in the constructor over the adapter now requires me to provide the adapter instance with hilt as well it seems. So what's the best practice , Philipp?

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

      you should always make glide a singleton, and therefore provide it. You don't need a provide function for the adapter if you inject stuff in the constructor and hilt knows how to create that stuff

    • @codinginflow
      @codinginflow 3 роки тому

      Glide is a singleton by default and it uses the fragment argument to handle cancellation of requests. You should actually not provide it from Dagger but instead call Glide.with() where you need it.

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

      that's new to me

    • @codinginflow
      @codinginflow 3 роки тому

      @@PhilippLackner Just follow the source code of Glide.with

    • @mehulbisht9708
      @mehulbisht9708 3 роки тому

      thank you both of you, you guys are amazing!

  • @SohailAnsari-ek3oy
    @SohailAnsari-ek3oy 2 роки тому +1

    ApplicationComponent is now replaced with SingletonComponent in the new version of hilt.

  • @techmarinar
    @techmarinar 3 роки тому

    Hey man thank you for the great explaining,🤩👍

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

    You are the best !!!

  • @h.r.60
    @h.r.60 3 роки тому +1

    Welcome back 😁

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

      Thanks :D

    • @h.r.60
      @h.r.60 3 роки тому

      @@PhilippLackner You're a legend. Godspeed

  • @fahrican9708
    @fahrican9708 3 роки тому

    good explanation, thanks!

  • @starlite5097
    @starlite5097 3 роки тому

    Thanks for the video, I will go next to the Spotify clone I think.

  • @anudeepananth
    @anudeepananth 3 роки тому +1

    Injecting a variable into a ViewModel with Hilt can be done easily with just a Companion Object right? Why do we need Hilt for that...

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

    Hey there. I get an error when trying to run the last thing you explained with the view model. When I replace the @InstallIn(ActivityComponent..) and @ActivityScoped annotations with @IntallIn(SingletoneComponent..) and @Singleton it works. I think it's because the MainModule which provides dependencies at an activity layer relies on the AppModule which provides dependencies at application level (because it's annotated as a singleton). Am I missing something?

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

    What if im depended on a runtime thing ?
    E.g
    On my app I have a number picker. With 1 and 2. If user select 1 I want to Inject X thing, if user select 2 I want to inject Y thing.
    This X and Y are the same type. Type of Z. So in my viewModel (or whenever this will be used) I want only to `@Inject lateinit var test: Z`.

  • @البرمجةللجميع-د4ظ
    @البرمجةللجميع-د4ظ 3 роки тому

    Perfect as always

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

    This video needs to be updated because the gradle dependencies that are mentioned are not correct at this time and the dependency for "hilt-lifecycle-viewmodel" isn't needed in the newer versions of the library (if it's added to your project, there will be runtime errors).

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

      That's why I pinned a comment with another video 😅

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

      @@PhilippLackner please remove this video; it's a bit confusing when there are 2 vids but only one of them is correct tutorial and you have to specifically read the comments to realize which one to follow 🤷🏾

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

    the TestViewModel example does not work with lastest hill versions.

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

    I am getting this error
    Execution failed for task ':app:kaptDebugKotlin'.
    How do I fix it?

  • @DARKcarlos1
    @DARKcarlos1 3 роки тому

    love this video. I have a question, what if I'm working with MVP (with Repository Pattern) and want to inject a room db instance and a retrofit instance? Do I need to inject roomdb and retrofit instances in the View, and send them as parameters to the presenter, and from presenter to the repository? thanks philipp for this tutorials, finally applying DI in my projects by watching your videos

    • @DjangoMx
      @DjangoMx 3 роки тому

      ok, si lo haces como dices estarias rompiendo el patron MVP ya que el framework en este caso android no debe llegar al Presenter, lo que tienes que hacer ahi es hacer una abstraccion de esas dependicias a una interface y usar estas en tu repository una vez que lo hagas al crear el provide del repo creas otra clase que implemente cada una de las interfaces antes mencionada es decir una que implemente la del localDataSource(Room) y otra que implemente el remoteDataSource(Retorfit) en cada una de ellas puedes pasar el context o cualquier otra dependencia que necesites y sera esta implementacion la que le pases al repository.
      Si necesitas ayuda escribeme por discord: DjangoMx

    • @DARKcarlos1
      @DARKcarlos1 3 роки тому

      @@DjangoMx suuper! trataré de hacer lo que me indicas, y si sigo perdido, te pido ayuda si es posible vale? Te agradezco mucho tu respuesta

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

    What if the variable string2 was created in the activity in a scenario like from IntentExtras and we need to pass it to the ViewModel without using a ViewModel factory

  • @erfansn869
    @erfansn869 3 роки тому

    very good

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

    how i can create a singleton viewmodel sheard between 2 screens

  • @albertbo2178
    @albertbo2178 3 роки тому

    When I try to inject to the activity the viewmodel like this fails to compile for this reason:
    Classifier 'RoutesListViewModel' does not have a companion object, and thus must be initialized here
    Anyone knows how to solve this?

  • @raghavaggarwal8644
    @raghavaggarwal8644 3 роки тому

    Hi Philipp thanks for the tutorial, after watching this beginner tutorial, which playlist of yours would u recommend if I want to start practically using Dependency Injection.

  • @vikashparajuli
    @vikashparajuli 3 роки тому

    I am want to create an android library (without Application Class, Activity and Fragment) using Hilt. Can you please help on that?

  • @unistern
    @unistern 3 роки тому

    nice vid. unfortunately hilt doesnt support DI in kotlin object . or do you know how to?

  • @shreyashchoudhary7413
    @shreyashchoudhary7413 3 роки тому

    Epic!

  • @matt-g-recovers
    @matt-g-recovers 3 роки тому

    Your library is nearly complete.
    It's missing a playlist for Dagger Hilt showing examples of various objects being injected into various logical places.

  • @fb767
    @fb767 3 роки тому

    I didn't understand one thing: At 6:45 you stated that you can have it live for an Activity (by using ActivityComponent), but how do you tell it which Activity specifically?

  • @imnithish
    @imnithish 3 роки тому +3

    they have already removed ApplicationComponent😭 also viewmodel inject is deprecated

  • @animeshbarai6804
    @animeshbarai6804 3 роки тому

    Why don't you again start full app series?. They are so much helpful ☺️☺️☺️🙏

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

      Why don't you build your own app with your own ideas and so on ?

  • @salamytech
    @salamytech 3 роки тому

    thanks a lot, but in hilt module ApplicationComponent replaced with SingletonComponent

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

    for a strange reason I used hilt version 2.35 and it didn't work for me, then I used hilt version 2.40.5 and it worked, maybe someone has experienced the same thing

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

    Is @Singleton is same as 'object' keyword in Kotlin?

  • @mrdeveloper4438
    @mrdeveloper4438 3 роки тому

    hi...can you tell me about kiosk application in android....this is more interesting...

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

    hey man, as always thanks for the great video, but i want to ask why don't u use koin for dependency injection? it is much much more simpler to use in my opinion

  • @AlgeriaHere
    @AlgeriaHere 3 роки тому

    Helpful Videos but i have little suggestion , since we sometimes want to inject an a value like for example 2 strings , we can differenciate between using @Named("") , in one my project i did that also with qualifiers , now if both can do the same job what is the difference between them thank you ?

  • @fourcade7851
    @fourcade7851 3 роки тому

    hello bro thanks for video ))))))) thanks

  • @georgenady7375
    @georgenady7375 3 роки тому

    perfect 👌

  • @rickyfreddy6963
    @rickyfreddy6963 3 роки тому

    I love your tutorials, but this one should have started with "what is dagger-hilt". I never heard of it and the title made me think you were going to teach me :p

  • @Monarch_943
    @Monarch_943 3 роки тому

    Is there a way to pass "myFragment" to the module? I used to do that in Dagger2 however I have no idea how to do it in Hilt

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

    how can u buy video course "

  • @vathsan3906
    @vathsan3906 3 роки тому

    make something similar for Timber too :)