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.
In plain terms
- 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.
Must act Top 5 of 12 that need code or config changes
What you must change
Breaking8
Renames module to lazyModule in some contexts.
modulelazyModulegetAll() 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-fuChanges the BeanDef constructor, updating its API signature.
BeanDefViewModel declarations requiring scope injection must now be inside a viewModelScope { } block.
viewModelScopeAutomatic ViewModel scope creation now requires ViewModel declarations inside the viewModelScope section; declarations outside resolve against the root scope.
viewModelviewModelScopeKoinApplication is reworked to start and stop on the Compose cycle.
KoinApplicationFixes Compose scope resolution with proper context handling and introduces ComposeContextWrapper to manage internal scope state.
ComposeContextWrapperPlatform2
Raises minSdk to 23 for Android.
minSdkRequires the Ktor EAP repository to be added to settings.gradle.kts.
Deprecations to plan for
Deprecated2
Deprecates CheckModules.
CheckModulesRestores CheckModules as deprecated code.
CheckModulesAPI changes
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