Skip to content

Upgrading io.insert-koin:koin-android 3 to 4

Breaking3.5.6 → 4.2.2Breaking9Platform2Deprecated2New67Changed91Fixed95Other74

BreakingUpgrade verdict

8 breaking changes and 2 platform requirement changes.

  • Renames module to lazyModule in some contexts.
  • getAll() now returns instances in declaration order, removing the previous default sorting.
  • The koin-fu module is gone; its functionality now lives in the Koin Annotations plugin.
  • Changes the BeanDef constructor, updating its API signature.
Top 5 of 12 that need code or config changes
Breaking8
Renames module to lazyModule in some contexts.
modulelazyModule
getAll() now returns instances in declaration order, removing the previous default sorting.
getAll()
Removes the koin-fu module, which moved to the Koin Annotations plugin.
koin-fu
Changes the BeanDef constructor, updating its API signature.
BeanDef
ViewModel declarations requiring scope injection must now be inside a viewModelScope { } block.
viewModelScope
Automatic ViewModel scope creation now requires ViewModel declarations inside the viewModelScope section; declarations outside resolve against the root scope.
viewModelviewModelScope
KoinApplication is reworked to start and stop on the Compose cycle.
KoinApplication
Fixes Compose scope resolution with proper context handling and introduces ComposeContextWrapper to manage internal scope state.
ComposeContextWrapper
Platform2
Raises minSdk to 23 for Android.
minSdk
Requires the Ktor EAP repository to be added to settings.gradle.kts.
Deprecated2
Deprecates CheckModules.
CheckModules
Restores CheckModules as deprecated code.
CheckModules

Generated by DepDelta from published JVM bytecode. Not mixed with prose notes.

  • removed: ctor StateViewModelFactory(Scope, ViewModelParameter)
  • removed: final class StateViewModelFactory extends AbstractSavedStateViewModelFactory
  • removed: method StateViewModelFactory.create(String, Class, SavedStateHandle): ViewModel
  • removed: method StateViewModelFactory.getParameters(): ViewModelParameter
  • removed: method StateViewModelFactory.getScope(): Scope
  • removed: method ScopeService.onCloseScope(): void
  • removed: method KoinFragmentFactory.getKoin(): Koin
  • removed: ctor LifecycleViewModelScopeDelegate(ComponentActivity, Koin, Function1)
  • removed: final class LifecycleOwnerExtKt
  • removed: final class LifecycleViewModelScopeDelegate implements ReadOnlyProperty
  • removed: method LifecycleViewModelScopeDelegate.getValue(LifecycleOwner, KProperty): Scope
  • removed: method RetainedScopeActivity.onCloseScope(): void
  • removed: method ScopeActivity.onCloseScope(): void
  • removed: method ScopeFragment.onCloseScope(): void
  • removed: method ScopeViewModel.closeScope(): void
  • removed: method ScopeViewModel.getKoin(): Koin
  • removed: static method FragmentExtKt.createScope(Fragment, Object): Scope
  • removed: static method LifecycleOwnerExtKt.getCurrentScope(LifecycleOwner): Scope
  • removed: static method LifecycleOwnerExtKt.getLifecycleScope(LifecycleOwner): Scope
  • removed: static method LifecycleOwnerExtKt.getScope(LifecycleOwner): Scope
  • changed: static method ComponentActivityExtKt.createScopeForCurrentLifecycle(ComponentCallbacks, LifecycleOwner): Scope → static method ComponentActivityExtKt.createScopeForCurrentLifecycle(ComponentCallbacks, LifecycleOwner, TypeQualifier): Scope
  • added: final class AndroidScopeArchetypesKt
  • added: static method AndroidScopeArchetypesKt.getActivityRetainedScopeArchetype(): TypeQualifier
  • added: static method AndroidScopeArchetypesKt.getActivityScopeArchetype(): TypeQualifier
  • added: static method AndroidScopeArchetypesKt.getFragmentScopeArchetype(): TypeQualifier
  • added: final class AndroidScopeArchetypesDSLKt
  • added: static method AndroidScopeArchetypesDSLKt.activityRetainedScope(Module, Function1): void
  • added: static method AndroidScopeArchetypesDSLKt.activityScope(Module, Function1): void
  • added: static method AndroidScopeArchetypesDSLKt.fragmentScope(Module, Function1): void
  • removed: ctor ViewModelOwner(ViewModelStoreOwner, SavedStateRegistryOwner)
  • removed: ctor ViewModelParameter(KClass, Qualifier, Function0, Function0, ViewModelStoreOwner, SavedStateRegistryOwner)
  • removed: final class GetViewModelKt
  • removed: final class ViewModelOwner
  • removed: final class ViewModelOwnerKt
  • removed: final class ViewModelParameter
  • removed: final class ViewModelResolverKt
  • removed: method ViewModelOwner.Companion.from(ViewModelStoreOwner): ViewModelOwner
  • removed: method ViewModelOwner.Companion.from(ViewModelStoreOwner, SavedStateRegistryOwner): ViewModelOwner
  • removed: method ViewModelOwner.Companion.fromAny(Object): ViewModelOwner
  • removed: method ViewModelOwner.getStateRegistry(): SavedStateRegistryOwner
  • removed: method ViewModelOwner.getStoreOwner(): ViewModelStoreOwner
  • removed: method ViewModelParameter.getClazz(): KClass
  • removed: method ViewModelParameter.getParameters(): Function0
  • removed: method ViewModelParameter.getQualifier(): Qualifier
  • removed: method ViewModelParameter.getRegistryOwner(): SavedStateRegistryOwner
  • removed: method ViewModelParameter.getState(): Function0
  • removed: method ViewModelParameter.getViewModelStoreOwner(): ViewModelStoreOwner
  • removed: static field ViewModelOwner.Companion: ViewModelOwner.Companion
  • removed: static final class ViewModelOwner.Companion
  • removed: static method GetViewModelKt.getViewModelKey(Qualifier, String, String): String
  • removed: static method GetViewModelKt.lazyResolveViewModel(KClass, Function0, String, Function0, Qualifier, Scope, Function0): Lazy
  • removed: static method GetViewModelKt.resolveViewModel(KClass, ViewModelStore, String, CreationExtras, Qualifier, Scope, Function0): ViewModel
  • removed: static method ViewModelResolverKt.pickFactory(Scope, ViewModelParameter): ViewModelProvider.Factory
  • removed: static method ViewModelResolverKt.resolveInstance(ViewModelProvider, ViewModelParameter): ViewModel
  • removed: final class ActivityStateVMKt
  • removed: final class BundleExtKt
  • removed: final class FragmentSharedStateVMKt
  • removed: final class FragmentSharedVMKt
  • removed: final class FragmentStateVMKt
  • removed: static method BundleExtKt.toExtras(Bundle, ViewModelStoreOwner): CreationExtras
  • removed: static method FragmentSharedStateVMKt.getSharedStateViewModel(Fragment, Qualifier, Function0, Function0, KClass, Function0): ViewModel
  • removed: static method FragmentSharedStateVMKt.sharedStateViewModel(Fragment, Qualifier, Function0, Function0, KClass, Function0): Lazy
  • removed: static method ViewModelLazyKt.getLazyViewModelForClass(KClass, ViewModelStoreOwner, Scope, Qualifier, Function0, String, Function0): Lazy
  • removed: ctor DefaultViewModelFactory(Scope, ViewModelParameter)
  • removed: ctor KoinViewModelFactory(KClass, Scope, Qualifier, Function0)
  • removed: final class DefaultViewModelFactory implements ViewModelProvider.Factory
  • removed: final class KoinViewModelFactory implements ViewModelProvider.Factory
  • removed: method DefaultViewModelFactory.create(Class): ViewModel
  • removed: method DefaultViewModelFactory.getParameters(): ViewModelParameter
  • removed: method DefaultViewModelFactory.getScope(): Scope
  • removed: method KoinViewModelFactory.create(Class, CreationExtras): ViewModel
  • removed: ctor AndroidParametersHolder(Function0, CreationExtras)
  • removed: final class AndroidParametersHolder extends ParametersHolder
  • removed: method AndroidParametersHolder.elementAt(int, KClass): Object
  • removed: method AndroidParametersHolder.getExtras(): CreationExtras
  • removed: method AndroidParametersHolder.getOrNull(KClass): Object
  • removed: final class ScopeExtKt
  • removed: static method ScopeExtKt.emptyState(): Function0