If you’re using Koin in a real Android or Kotlin project, chances are it’s already doing its job: wiring dependencies, keeping things readable, and staying out of your way.
But as apps grow, a few small DI decisions can quietly turn into performance issues, memory overhead, or runtime crashes.
In a recent video, Philipp Lackner shares three practical Koin tips that come directly from working on real-world codebases.
factoryOf vs singleOf intentionally — don’t default blindlyMany teams default to singleOf for nearly everything. It feels convenient — you declare a dependency once and reuse it everywhere.
But here’s the trade-off:
singleOf creates a long-lived singleton.
factoryOf creates a fresh instance each time it’s requested.
Why does that matter?
Consider use cases or screen-specific operations. These usually hold UI-related state and don’t need to exist beyond a ViewModel. If you define them as factories, they:
✔ live only as long as the ViewModel
✔ avoid global shared state
✔ reduce memory footprint
Singletons still have their place — databases, data stores, file systems, and HTTP clients are expensive to create and deserve a single shared instance.
Rule of thumb:
If an object is light and tied to screen or business logic, prefer
factoryOf.
If it is expensive and broadly reused, choosesingleOf.
You forget to provide a dependency → the app compiles fine → it crashes only when the specific screen asks for it.
Large apps amplify this risk — more screens, more flows, and more paths nobody tests.
There’s a simple fix.
Kotzilla created a free Koin IDE Plugin that:
visualizes your dependency graph
highlights missing bindings
gives you quick navigation to problem spots
Instead of waiting for a runtime crash, you can spot missing declarations directly in your IDE. Refresh the graph, scan for warnings, and fix before shipping — simple, but a huge reliability gain.
Because Koin knows your full dependency graph, it can help you understand performance bottlenecks.
The same plugin exposes Koin Insights, a dashboard that detects things like:
slow dependency resolution
blocking operations on the main thread
overly complex dependency structures
It doesn’t just warn you — it explains what’s wrong and where to look.
init {}.factoryOf to singleOf.There’s even built-in AI assistance that can suggest (or generate) fixes based on your actual graph — a useful starting point before refactoring.
We've published a sandbox so you can see for yourself with no setup required
Koin already keeps dependency management clean. With a few mindful choices like early error detection, and graph-based analysis — you can:
reduce crashes
simplify architecture
improve performance