| Feature | CameraX 1.5 Support |
|---|---|
| Zero-Shutter Lag | ✅ CAPTURE_MODE_ZERO_SHUTTER_LAG (since 1.2) |
| 120/240fps Slow-Motion | ✅ HighSpeedVideoSessionConfig |
| RAW/DNG Capture | ✅ OUTPUT_FORMAT_RAW / OUTPUT_FORMAT_RAW_JPEG |
| HDR + 60fps + Stabilization | ✅ Feature Group API |
| Manual ISO/Shutter | ✅ Via Camera2Interop |
| Concurrent Cameras | ✅ ConcurrentCamera API |
| Aspect | Koin Annotations (KSP) | Koin Compiler Plugin |
|---|---|---|
| Compile-time verification | ✅ | ✅ |
| Classes must be annotated | ✅ Required (@Single, @Factory) |
❌ Optional |
| DSL gets compile-time wiring | ❌ | ✅ |
| Requires KSP Gradle setup | ✅ | ❌ |
| Separate build step | ✅ (KSP runs separately) | ❌ (runs during normal compilation) |
| Incremental build impact | Slower | Faster |
| Feature | Hilt | Koin (Current) | Koin (With Plugin) |
|---|---|---|---|
| Compile-time verification | ✅ | ❌ (unless Annotations) | 🔜 (coming soon) |
| KMP support | ❌ | ✅ | ✅ |
| No annotation processing | ❌ | ✅ | ✅ |
| Coding Style | Annotations Mandatory | DSL (Standard) | Hybrid (DSL or Native Annotations) |
| Clean DSL | ➖ | ✅ | ✅✅ (Concise: single<T>()) |
| Requires KAPT/KSP | ✅ (KAPT/KSP) | ❌ (or ✅ KSP if using Annotations) | ❌ (Native Compiler) |
| Build speed | Slower (due to KAPT/KSP) | Fast | Fast (No KSP overhead) |
| Runtime lookup | Direct factory reference | Key-based (~0.005ms) | Reduced overhead |
| Parameter Type | Generated Code |
|---|---|
val repo: Repository |
get() |
val config: Config? = null |
getOrNull() |
val lazy: Lazy<Service> |
inject() |
@Named("prod") val db: Database |
get(named("prod")) |
@InjectedParam val id: String |
it.get() |
| Component | Scope | Lifetime |
|---|---|---|
| SingletonComponent | @Singleton | Entire app |
| ActivityRetainedComponent | @ActivityRetainedScoped | Survives configuration changes |
| ViewModelComponent | @ViewModelScoped | ViewModel lifetime |
| ActivityComponent | @ActivityScoped | Activity lifetime |
| FragmentComponent | @FragmentScoped | Fragment lifetime |
| Aspect | True DI (Hilt) | Service Locator (Koin DSL) |
|---|---|---|
| Compile-time | Generates factory classes | Generates definition lambdas |
| Runtime lookup | Direct factory reference (type-safe graph) | Definition index by key (~0.005ms) |
| Instance creation | Runtime (via factory.get()) |
Runtime (execute lambda) |
| Missing dependency | Build fails | Runtime crash (or build fails with Annotations/Plugin) |
| Build time | Slower (annotation processing) | Faster (no KSP/KAPT) |
| Your classes | Framework-agnostic | Framework-agnostic |
| Manual DI | With a Framework |
|---|---|
| You write the container class | Framework generates/manages it |
| You manually track dependencies | Framework builds the dependency graph |
| You manage object lifecycles | Framework handles scoping automatically |
| Errors surface at runtime | Errors caught at compile time (Hilt) or startup (Koin) |
| Android components need workarounds | Framework integrates directly with Activities, Fragments, ViewModels |
| Constraint | Winner |
|---|---|
| Kotlin Multiplatform | Koin (Hilt doesn't work) |
| Must have compile-time DI verification | Hilt, or Koin with Annotations/Plugin |
| Slow builds are blocking productivity | Koin |
| Team already knows Dagger | Hilt |
| Team new to DI | Koin |
| Google/Jetpack alignment required | Hilt |
| Runtime performance | Both fast (Hilt: direct reference, Koin: ~0.005ms lookup) |
| Aspect | Hilt | Koin |
|---|---|---|
| Compile-time | Generates factory classes | Generates definition lambdas |
| Runtime lookup | Direct factory reference (type-safe graph) | Definition index by key (~0.005ms) |
| Instance creation | Runtime (via factory.get()) |
Runtime (execute lambda) |
| Missing dependency | Build fails | Runtime crash (or build fails with Annotations/Plugin) |
| Build time | Slower (annotation processing) | Faster (no KSP/KAPT) |
| Your classes | Framework-agnostic | Framework-agnostic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Composable | |
| fun <T>ObserveEffects( | |
| flow: Flow<T>, | |
| key1: Any? = null, | |
| key2: Any? = null, | |
| onEvent: suspend (T) -> Unit | |
| ) { | |
| val lifecycleOwner = LocalLifecycleOwner.current | |
NewerOlder