Adding Hilt to Multi-Module App | Android 2024

  Рет қаралды 3,044

The Android Factory

The Android Factory

Күн бұрын

Пікірлер: 26
@king-rabbit
@king-rabbit Ай бұрын
Great first look into DI with Hilt.
@TheAndroidFactory
@TheAndroidFactory Ай бұрын
Appreciate the support!
@hinocenciopaulo
@hinocenciopaulo 7 ай бұрын
Every time I hear your intro, I automatically give the video thumbs up. 😂
@TheAndroidFactory
@TheAndroidFactory 7 ай бұрын
Hahaha I have said it so many times now it is just a staple of the content at this point. I appreciate your support 🙌
@god_bika
@god_bika Ай бұрын
Doesnt multimodule suppose you to have to add another @module-ed file at least? Or am i getting something wrong?
@TheAndroidFactory
@TheAndroidFactory Ай бұрын
Sorry, this is specifically talking about modules for the project, not just module-annotated files as it relates to Hilt. So for this project we have an 'app' module (the standard one) and also a 'network' module (that has a bunch of our network related code). These modules are a bit different than the files annotated @Module
@nicoqueijo
@nicoqueijo 5 ай бұрын
6:01 how did you highlight an instance of VERSION_11 and quickly highlighted the other two for quick editing?
@TheAndroidFactory
@TheAndroidFactory 5 ай бұрын
I think it is Alt + j on Windows and CTRL + g on Mac! Super useful shortcut once you get the hang of it. Copy and paste over multiple cursors works too which is satisfying 😎
@nicoqueijo
@nicoqueijo 5 ай бұрын
How come the hilt NetworkModule doesn't reside in the network module? For di, are all the hilt modules supposed to reside in the app module?
@TheAndroidFactory
@TheAndroidFactory 5 ай бұрын
Hey this is a great question, but no we want this DI module in the app module because we are using Hilt in the app to inject our networking "library" into the main module. If you had dependencies you needed to organize in the network module to make that function properly, you could use Hilt again in that module to map your dependencies. Does that make sense?
@nicoqueijo
@nicoqueijo 5 ай бұрын
@@TheAndroidFactory I think so. So if I have a Repository in a data module that uses a KtorClient (that resides in the network module) I would make the NetworkModule (that provides the KtorClient) inside the data module, correct?
@TheAndroidFactory
@TheAndroidFactory 5 ай бұрын
Yes, correct. You use the Hilt modules inside your modules that contain the code to either (1) map dependencies your module needs internally for itself to work or (2) fetch dependencies from "outside" your module that your code depends on to operate.
@nicoqueijo
@nicoqueijo 5 ай бұрын
@@TheAndroidFactory Thank you so much for the explanations!
@TheAndroidFactory
@TheAndroidFactory 5 ай бұрын
Of course! Hope it helps :)
@shaharts8333
@shaharts8333 9 ай бұрын
Thanks for sharing
@TheAndroidFactory
@TheAndroidFactory 9 ай бұрын
Thanks for following!
@GCkk
@GCkk 4 ай бұрын
Hi, Is their a way to inject the applicationContext into multi-module lib?
@TheAndroidFactory
@TheAndroidFactory 4 ай бұрын
For sure! Checkout this StackOverflow post: stackoverflow.com/questions/63072927/how-to-inject-application-context-in-a-repository-with-hilt
@GCkk
@GCkk 4 ай бұрын
@@TheAndroidFactory Sorry I think Question was not clear. I wish inject the applicationContext of the app to a library module.
@TheAndroidFactory
@TheAndroidFactory 4 ай бұрын
@GCkk yeah it could be done by defining an interface in the library module that needs application context, and is implemented in the app module. I'd consider alternate ways of doing this as well though as a thought exercise, for instance: do you actually need the application context as opposed to another context? Is there a way you can restructure things so whatever needs the application context can be injected into the library as opposed to the library requiring the context itself? It may not be wrong what you're doing, but it may be easier if you try to solve the problem a different way. Just something to think about! Hope this helps
@engineerfred9427
@engineerfred9427 8 ай бұрын
🥰🥰 thank you
@engineerfred9427
@engineerfred9427 8 ай бұрын
thank you very much for this...🥰
@TheAndroidFactory
@TheAndroidFactory 8 ай бұрын
I'm glad it was helpful :)
MVVM + Hilt + Compose Navigation Masterclass | Android 2024
18:53
The Android Factory
Рет қаралды 2,6 М.
Don't Do These Fatal Mistakes With a Multi-Module Architecture
10:19
Philipp Lackner
Рет қаралды 42 М.
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 34 МЛН
How to whistle ?? 😱😱
00:31
Tibo InShape
Рет қаралды 23 МЛН
Бенчик, пора купаться! 🛁 #бенчик #арти #симбочка
00:34
Симбочка Пимпочка
Рет қаралды 4 МЛН
Multi-module Android App Tutorial
17:04
The Android Factory
Рет қаралды 11 М.
Introduction to Ktor by Tomas Zezula
31:32
Kotlin Server Squad
Рет қаралды 1,1 М.
Модули в Android Clean Architecture на практике
20:57
Тимофей Коваленко
Рет қаралды 26 М.
Hilt - лёгкий старт в Dagger
32:26
Android Broadcast. Все об Андроид разработке
Рет қаралды 14 М.
Master Flutterflow API Integration: Complete App Tutorial
34:08
just xolotl
Рет қаралды 9 М.
Setup Ktor for your Android app!
15:22
The Android Factory
Рет қаралды 6 М.
How to handle network errors with Ktor
10:37
The Android Factory
Рет қаралды 1,7 М.
Dagger Hilt - Assisted Inject Hilt in Android!
9:31
Charfaoui Younes
Рет қаралды 1,5 М.
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 34 МЛН