The Ultimate Guide to Koin (Dependency Injection with Kotlin) - Android Studio Tutorial

The Ultimate Guide to Koin (Dependency Injection with Kotlin) - Android Studio Tutorial

Philipp Lackner

2 года назад

46,883 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Tikhon
Tikhon - 21.08.2023 19:51

Soo easy to use koin, hello from russia)

Ответить
Jephte
Jephte - 08.08.2023 00:18

Thank you so much!

Ответить
Ren
Ren - 07.08.2023 09:53

this is such a nice video. Thanks Philipp.

Ответить
Shivam Kadam
Shivam Kadam - 05.08.2023 10:14

I like koin more

Ответить
Tayfun Cesur
Tayfun Cesur - 25.07.2023 11:23

When you say, "most people overcomplicated", it reminded me of the old dagger documentation which gives the thermosiphon example 😃
Nice video btw, thanks!

Ответить
Helder Ventura
Helder Ventura - 16.06.2023 13:03

'....don't wanna talk about the life of a programmer' 😂😂😂

Ответить
Kotzilla
Kotzilla - 19.01.2023 14:32

Thanks a lot Philipp for your guide, really great work 🙏

Ответить
pratik Bohir
pratik Bohir - 07.12.2022 13:24

so which one is good hit or koin?

Ответить
KIGAMING
KIGAMING - 01.11.2022 12:37

how to inject constructor?

Ответить
Sodiqjon Rasulov
Sodiqjon Rasulov - 30.10.2022 17:57

It's really helpful. Thanks Lackner

Ответить
Luis Enrique Mendez Cantero
Luis Enrique Mendez Cantero - 14.10.2022 23:51

Nice explanation! THX

Ответить
Johannes Bester
Johannes Bester - 13.09.2022 11:22

The main difference is that Koin is a PURE Kotlin library and Hilt NOT, therefore Koin can be used in KMM/D-KMP projects where Hilt cannot!

Ответить
azzum waqar
azzum waqar - 22.08.2022 11:37

Philipp - I am trying to use mockito to mock an object that is passed as an argument to the constructor of myViewModel(val dice:Dice).

within the Dice class I just have a single method called roll() that just returns a random number between 1..6. It is not
It is not returning 3?


This is how my instrumentation setup:

@Before
fun init(){
stopKoin()
diceMock = mock(Dice::class.java)
`when`(diceMock.roll()).thenReturn(3)

val testModule = module {

single { diceMock }
viewModel{
DiceViewModel(diceMock)
}
}

startKoin{
// loadKoinModules(testModule)
modules(testModule)
}
}

@Test
fun roll_displaysNumber() {
`when`(diceMock.roll()).thenReturn(3)

onView(withId(R.id.button)).perform(click())

onView(withId(R.id.textView)).check(matches(isDisplayed()))
}

Ответить
azzum waqar
azzum waqar - 20.08.2022 20:39

Excellent tutorial bro - very relevant..

Ответить
Eman Nollase
Eman Nollase - 18.08.2022 14:22

this is awesome! QQ: what if in the viewmodel constructor we need 2 or more dependency? how we inject that dependency? thanks

Ответить
View 2637 replies
View 2637 replies - 04.08.2022 17:11

Wow you make it very understandable. Thank you

Ответить
ShaqGames
ShaqGames - 03.08.2022 21:38

I'm looking into Koin after just getting really frustrated with Dagger Hilt and wow this is much easier and more flexible than hilt is. Time to migrate to Koin!

Ответить
Azamat 01
Azamat 01 - 24.06.2022 13:59

Single = The life of a programmer😂

Ответить
Reidara
Reidara - 30.05.2022 20:54

What if my adapter looks like this RouteAdapter(val clickCallback: (Route) -> Unit
Then we are creating what inside module? :D

and what if my repository looks like this
class Repository(
private val routeApi: RouteApi,
private val RouteCacheDataSource: RouteCacheDataSource
) and my koin need this 2 dependency? ^^ just we have to use Repository(get(), get()) ?: P

Ответить
Function and Form
Function and Form - 17.05.2022 03:39

Hey! Great video :D Can you do any tutorials on Anvil? It seems the community is really lacking some solid examples of its usage.

Ответить
Freediving Trainer
Freediving Trainer - 15.05.2022 15:55

What about preview? How to organise preview with viewModel and Koin? ay be a good them for video)

Ответить
Anudeep Ananth
Anudeep Ananth - 15.05.2022 07:13

Could you do a video on baseline profiles, looks like a great way to increase app start performance

Ответить
clamum
clamum - 12.05.2022 07:13

Btw big 🐕 isn't it pronounced the same as "coin" is, like the little metal pieces of currency?

Ответить
clamum
clamum - 12.05.2022 06:57

"Single, but I'm not talking about the life of a programmer"

🤭
...
🤔
🥺🔫

Looks like KOIN might be a little easier to setup than Dagger/Hilt. Not that that's difficult but there is a series of things you need to setup to use it. May check out KOIN for my next project thanks for showing it big 🐕

Ответить
Facundo Bayo
Facundo Bayo - 10.05.2022 23:18

With you i learn Android and english :D

Ответить
Shariar Hossain
Shariar Hossain - 08.05.2022 06:05

Hello sir can you make a tutorial about mobile banking apps. like Bkash is very advance apps in Bangladesh.

Ответить
Amit Kundu
Amit Kundu - 07.05.2022 07:35

I love to watch your videos 😍

Ответить
Muneer Hasan
Muneer Hasan - 06.05.2022 19:46

Thanks for making this video.

Ответить
Soothing Life
Soothing Life - 06.05.2022 05:47

Thank you for the video , very helpful

Ответить
AKASH KUMAR DAS
AKASH KUMAR DAS - 05.05.2022 19:14

I worry about you, how you provide such great contents for free? Thank you so much sir.

Ответить
Mustafa Ammar
Mustafa Ammar - 05.05.2022 18:06

Very cool video
thank you bro wish you all the best 👍👍👍🔥🔥🔥🔥

Ответить
Rijal Muhyidin
Rijal Muhyidin - 05.05.2022 14:35

Clear explanation. Thanks philipp

Ответить
Anuranjan Srivastava
Anuranjan Srivastava - 05.05.2022 11:52

Koin being an easy to use service locater without any proxies, code generation or reflection can attract many people.

Ответить
Oliver Griffin
Oliver Griffin - 05.05.2022 11:17

Wait, you're telling me it isn't said "Coin"?!?

Ответить
Arfin Hosain
Arfin Hosain - 05.05.2022 08:44

You still use koin on your project?

Ответить
Josua Hutapea
Josua Hutapea - 05.05.2022 08:24

what color theme is that?

Ответить
Unaisul Hadi
Unaisul Hadi - 05.05.2022 07:53

Really helpful, I was unaware of how to handle named injection like Hilt. Thanks

Ответить
Mohit369
Mohit369 - 05.05.2022 07:46

Can you teach how to make website using kotlin or please link any tutorial below

Ответить
Christian Camilo Otero
Christian Camilo Otero - 04.05.2022 20:09

Just the video I was needing. Thank you!

Ответить
Matt Graves
Matt Graves - 04.05.2022 19:31

Nice...reminds me.
.have you done KTOR?
I need to review your library again

Ответить
You Me and Everyone
You Me and Everyone - 04.05.2022 19:11

Wow man. Respect.

Ответить
Tilted by Box
Tilted by Box - 04.05.2022 18:33

Koin isn't dependency injection actually. It's a service locator. The end result is pretty much the same, both provide dependency, however they do it differently and hilt does it much faster, because it's done at compile time. In other words Koin has no build time impact, but has a runtime one. The opposite is true for hilt.

Ответить
Who Knows
Who Knows - 04.05.2022 18:04

I always find DI at runtime kinda dangerous. When you have multiple flow, it is easy to miss one and you will only notice when running it.

Ответить