AI Briefing
KO

Banksalad Migrates DI from Koin to Hilt… Resolves Runtime Crashes

·2022.04.09 09:00

Key point

Banksalad migrated to Dagger Hilt to solve Koin's runtime dependency injection issues.

Details

Banksalad's Android team migrated their existing DI tool, Koin, to Dagger Hilt to solve runtime crashes and increasing management difficulty in their Clean Architecture-based app. While Koin has a low learning curve due to its Kotlin DSL and runtime injection approach, performance degradation from reflection usage and the absence of compile-time verification acted as fundamental limitations.

In particular, the difficulty in tracking instance references and identifying Entry Points caused by overuse of koin.get() led to frequent crashes that were not caught during the QA stage. To secure dependency visibility across hundreds of screens and a multi-module structure, the team set this as a Q2 2021 epic and pursued a systematic migration.

Key Reasons for Adopting Hilt

Hilt verifies the dependency graph at build time through Annotation Processing, eliminating the risk of Koin's runtime errors. The main advantages are as follows.

  • Compile-time verification: Dependency cycles or omissions are immediately discovered at the build stage.
  • Performance improvement: Reduces runtime overhead by using generated Java Stub files instead of reflection.
  • AAC ViewModel support: ViewModel injection is possible with the @HiltViewModel annotation without a separate library.

Migration Strategy and Modularization Rules

Instead of changing the entire codebase at once, the team adopted a strategy of gradual application on a module-by-module basis. They established an 11-step migration plan and distributed guidelines after verifying for conflicts through a PoC (Proof of Concept).

The module naming conventions and structure for applying Hilt were standardized as follows.

  • Activity/Fragment: Automatic injection via the @AndroidEntryPoint annotation
  • ViewModel: Use of the @HiltViewModel annotation
  • Module: Separated into XXModule, RepositoryModule, UseCaseModule, etc., depending on the injection target
  • Scope: Object lifecycle is managed by specifying @Singleton or a custom Scope

Through this process, Banksalad enhanced the stability of dependency injection and secured ease of writing test code and refactoring.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.