2.2.0-RC1
What's Changed
This major release introduces powerful new features for application configuration, JSR-330 compatibility, advanced scoping, and significant performance improvements. Perfect for teams migrating from other DI frameworks and building large-scale applications.
New Features
Application Configuration System
New @KoinApplication and @configuration annotations for enterprise-grade application management
- @KoinApplication: Bootstrap entry point annotation that generates both startKoin() and koinApplication() functions
- @configuration: Organize modules into environments, flavors, and feature sets
- Multi-environment support: Easily switch between development, production, test configurations
- Generated bootstrap functions: Support custom lambda configuration blocks
@KoinApplication(configurations = ["default", "production"])
class ProductionApp
// Generates: MyApp().startKoin { /* custom config */ }
Scope Archetype Annotations
Predefined scope annotations for common patterns - no more manual scope declarations
Android Scope Archetypes:
- @ActivityScope: Activity-scoped components
- @ActivityRetainedScope: Survives configuration changes
- @FragmentScope: Fragment-scoped components
Cross-Platform Scope Archetypes:
- @ViewModelScope: KMP-compatible ViewModel scoping for Android, iOS, Desktop, Web
@ActivityScope
class LocationService(val context: Context)
@ViewModelScope // Works across all KMP targets!
class SharedRepository(val api: ApiService)
JSR-330 Compatibility Layer
New koin-jsr330 module for seamless framework migration
Perfect for teams migrating from Hilt, Dagger, Guice, or other JSR-330 frameworks:
- @singleton (jakarta.inject.Singleton) - equivalent to @single
- @nAmed (jakarta.inject.Named) - JSR-330 standard qualifiers
- @Inject (jakarta.inject.Inject) - constructor injection marking
- @qualifier & @scope - meta-annotations for custom annotations
- Mixed usage: Use JSR-330 and Koin annotations in the same project
// JSR-330 style - familiar to Dagger/Hilt developers
@singleton
@nAmed("primary")
class DatabaseService @Inject constructor(val config: DbConfig)
Custom KSP Path Generation
You can now benefit from generating Koin code into the desired package, by using the KSP_GENERATION_PACKAGE KSP option, to specify teh target package.
See https://insert-koin.io/docs/reference/koin-annotations/options#koin_generation_package for more info.
Performance & Reliability Improvements
Major Performance Optimizations
- O(n*m) → O(1) module lookup: Cached package mappings for instant module resolution
- Optimized property association: O(n) complexity instead of O(n*m)
- Streamlined definition processing: Reduced memory allocation during compilation
- External definition caching: Hierarchical package matching for fast lookups
- Metadata scanning optimizations: Index-based scanning with batch processing
Enhanced Compile Safety
- Reworked configuration checking: More robust validation at compile time
- Improved error handling: Better diagnostics for invalid symbol detection
- Module path scanning: Enhanced accuracy for cross-module dependencies
- Tag management improvements: Cleaner metadata generation and verification
Developer Experience Improvements
Comprehensive Documentation
- Complete annotation reference: All annotations now documented with examples
- Framework migration guides: Specific guidance for Hilt/Dagger migration
- KMP compatibility notes: Clear multi-platform usage guidance
- Performance optimization tips: Best practices for large codebases
Enhanced Testing & Validation
- Expanded test coverage: All new features thoroughly tested
- Cross-platform validation: KMP compatibility verified across targets
- Performance benchmarks: Validated performance improvements in large codebases
Additional Enhancements
Improved Component Scanning
- Enhanced @componentscan: Better handling of package hierarchies
- Cross-module scanning: Improved Gradle module traversal
- Glob pattern support: Advanced package filtering capabilities
Better Module Management
- Module includes optimization: Faster module dependency resolution
- External module association: Improved handling of external definitions
- Configuration-based loading: Smart module loading based on active configurations
Updating your project & Migration
For New Projects:
- Use @KoinApplication + @configuration for organized application structure
- Leverage scope archetypes (@ViewModelScope, @ActivityScope) for common patterns
- Consider JSR-330 annotations if team has Dagger/Hilt experience
For Existing Projects:
- Zero breaking changes: All existing code continues to work
- Gradual adoption: Add new features incrementally
- Performance gains: Automatic performance improvements without code changes
For Framework Migration:
- Hilt/Dagger users: Start with koin-jsr330 module for familiar annotations
- Enterprise teams: Use @configuration for environment-specific modules
- KMP projects: Leverage @ViewModelScope for shared business logic
Full Changelog: 2.1.1-RC1...2.2.0-RC1