---
title: Getting Started with Koin Annotations 1.4 in Compose Multiplatform
description: Streamline your Compose Multiplatform project by migrating from Koin DSL to Koin Annotations 1.4. Learn dependency setup, component migration, and platform implementations.
image: https://blog.kotzilla.io/hubfs/Screenshot%202024-10-24%20at%2012.03.30.png
---

[Skip to content](https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform#main-content)

[![kotzilla (3)](https://blog.kotzilla.io/hubfs/kotzilla%20(3).svg)](https://kotzilla.io/)

- [Koin](https://insert-koin.io/)
- [Koin IDE Plugin](https://plugins.jetbrains.com/plugin/26131-koin-dependency-injection-official-)
- [Koin LTS](https://kotzilla.io/koin-lts)
- [Developer Hub](https://doc.kotzilla.io/)

Open main navigation

Close main navigation

- [Koin](https://insert-koin.io/)
- [Koin IDE Plugin](https://plugins.jetbrains.com/plugin/26131-koin-dependency-injection-official-)
- [Koin LTS](https://kotzilla.io/koin-lts)
- [Developer Hub](https://doc.kotzilla.io/)
- [Contact us](https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform#contact)

[Contact us](https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform#contact)

 Oct 17, 2024, 3:44:50 PM

# Getting Started with Koin Annotations 1.4 in Compose Multiplatform

[The Kotzilla Team](https://blog.kotzilla.io/author/the-kotzilla-team)

Share: [facebook-f icon](http://www.facebook.com/share.php?u=https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform) [linkedin-in icon](http://www.linkedin.com/shareArticle?mini=true&url=https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform) [Twitter icon](https://twitter.com/intent/tweet?url=https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform) [pinterest-p icon](http://pinterest.com/pin/create/link/?url=https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform) [envelope icon](mailto:?body=https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform)

![Getting Started with Koin Annotations 1.4 in Compose Multiplatform](https://139572340.fs1.hubspotusercontent-eu1.net/hub/139572340/hubfs/Screenshot%202024-10-17%20at%2015.18.23.png?width=1200&length=1200&name=Screenshot%202024-10-17%20at%2015.18.23.png)

If you've been using Koin's DSL for dependency injection in your Kotlin Multiplatform projects, you might be interested in exploring a more annotation-driven approach. In this guide, Arnaud walks you through migrating a simple [Compose Multiplatform](https://www.jetbrains.com/compose-multiplatform/) application from Koin DSL to the new [Koin Annotations 1.4.](https://insert-koin.io/docs/reference/koin-annotations/start)

## Project Overview

We'll be working with the [KMP App Template](https://github.com/InsertKoinIO/KMP-App-Template/?tab=readme-ov-file#using-koin-annotations) from JetBrains, which provides a great starting point for our exploration. The data displayed by the app is from [The Metropolitan Museum of Art Collection API](https://metmuseum.github.io/).  This app already uses [Koin](https://insert-koin.io/) for dependency injection. This template implements this simple art gallery application that displays a list of paintings and their details. While the functionality is straightforward, it serves as an excellent example to demonstrate Koin's annotation-based dependency injection. And bonus : it's beautiful to look at. 

## Setting Up Dependencies

Before diving into the migration, let's ensure we have all the necessary dependencies:

![Screenshot 2024-10-25 at 09.03.09](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-25%20at%2009.03.09.png?width=651&height=204&name=Screenshot%202024-10-25%20at%2009.03.09.png)

Don't forget to set up [KSP (Kotlin Symbol Processing)](https://mvnrepository.com/artifact/com.google.devtools.ksp/symbol-processing-api/1.9.24-1.0.20) in your project, as it's essential for annotation processing.

## Project Structure

Our sample application follows a clean architecture approach with the following key components:

- Data Layer: 
    - `MuseumAPI`: Handles remote data fetching
    - `MuseumRepository`: Manages data operations
    - `MuseumStorage`: Handles local data persistence
- UI Layer: 
    - List Screen: Displays paintings grid
    - Detail Screen: Shows painting details
    - ViewModels: Manages UI state and business logic

## Migrating to Koin Annotations

### Step 1: View Model Migration

Let's start by migrating our view models from DSL to annotations. Replace the existing DSL module definition:

![Screenshot 2024-10-25 at 09.03.45](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-25%20at%2009.03.45.png?width=637&height=220&name=Screenshot%202024-10-25%20at%2009.03.45.png)

### Step 2: Data Layer Migration

Next, let's tackle the data layer components:

![Screenshot 2024-10-25 at 09.04.32](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-25%20at%2009.04.32.png?width=607&height=287&name=Screenshot%202024-10-25%20at%2009.04.32.png)

### Step 3: Complex Initializations

For more complex scenarios where you need custom initialization logic, you can use separate functions with the `@Single` annotation:

![Screenshot 2024-10-17 at 15.08.46](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-17%20at%2015.08.46.png?width=598&height=241&name=Screenshot%202024-10-17%20at%2015.08.46.png)

## Platform-Specific Components

One of the powerful features of Koin Annotations is its support for platform-specific implementations. Here's how to set it up:

![Screenshot 2024-10-25 at 09.05.21](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-25%20at%2009.05.21.png?width=633&height=645&name=Screenshot%202024-10-25%20at%2009.05.21.png)

## Benefits of Using Koin Annotations

**🔸 Cleaner Code**: Annotations provide a more declarative and concise way to define dependencies  
**🔸 Better IDE Support**: Enhanced code navigation and refactoring capabilities  
**🔸 Compile-Time Validation**: Earlier detection of dependency injection issues  
**🔸 Reduced Boilerplate**: KSP generates necessary extension functions automatically  
**🔸 Platform-Specific Support**: Seamless handling of platform-specific dependencies

## Wrapping Up

Migrating from Koin DSL to Annotations might require some initial setup, but the benefits in terms of code clarity and maintainability are well worth it. The annotation-based approach provides a more familiar paradigm for developers coming from other dependency injection frameworks while maintaining Koin's lightweight and Kotlin-first philosophy.

Remember to check out the [official Koin documentation](https://insert-koin.io/) for more detailed information and advanced usage scenarios. Tell us what you think!

[Koin](https://blog.kotzilla.io/tag/koin), [Android](https://blog.kotzilla.io/tag/android), [Koin Annotations](https://blog.kotzilla.io/tag/koin-annotations), [Kotlin](https://blog.kotzilla.io/tag/kotlin), [KMP](https://blog.kotzilla.io/tag/kmp)

## Related posts

[![How to Migrate from Dagger2/Hilt to Koin for KMP](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-24%20at%2012.22.31.png?height=200&name=Screenshot%202024-10-24%20at%2012.22.31.png)](https://blog.kotzilla.io/migrate-from-hilt-to-koin)

[Koin](https://blog.kotzilla.io/tag/koin), [Kotlin](https://blog.kotzilla.io/tag/kotlin), [Dependency Injection](https://blog.kotzilla.io/tag/dependency-injection), [Hilt](https://blog.kotzilla.io/tag/hilt), [Dagger](https://blog.kotzilla.io/tag/dagger)

## [How To Migrate from Hilt to Koin - A Detailed Guide](https://blog.kotzilla.io/migrate-from-hilt-to-koin)

[The Kotzilla Team](https://blog.kotzilla.io/author/the-kotzilla-team) 

 Jul 23, 2024, 3:20:39 PM

Migrating from Hilt to Koin might seem daunting at first, but it's actually more manageable than...

[Read more](https://blog.kotzilla.io/migrate-from-hilt-to-koin)

[![Koin IDE Plugin releases page showing Koin Annotations 2.2 support in version 1.5.1 for Android and Kotlin dependency injection](https://blog.kotzilla.io/hs-fs/hubfs/Whats%20new%20November%202024%20(1).png?height=200&name=Whats%20new%20November%202024%20(1).png)](https://blog.kotzilla.io/koin-ide-plugin-1-5-1-annotations-2-2-jsr-330-android-kotlin)

[Koin Annotations](https://blog.kotzilla.io/tag/koin-annotations), [Kotzilla Platform](https://blog.kotzilla.io/tag/kotzilla-platform), [Koin IDE Plugin](https://blog.kotzilla.io/tag/koin-ide-plugin), [Debugging](https://blog.kotzilla.io/tag/debugging)

## [Koin IDE Plugin 1.5.1: Koin Annotations 2.2 Support with JSR-330 Compatibility](https://blog.kotzilla.io/koin-ide-plugin-1-5-1-annotations-2-2-jsr-330-android-kotlin)

![Picture of Art Shendrik](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-12-09%20at%2013.21.54.png?width=50&name=Screenshot%202024-12-09%20at%2013.21.54.png) [Art Shendrik](https://blog.kotzilla.io/author/art-shendrik) 

 Nov 10, 2025, 4:00:55 PM

In this update, we've achieved compatibility with Koin Annotations 2.2, unlocking the power of...

[Read more](https://blog.kotzilla.io/koin-ide-plugin-1-5-1-annotations-2-2-jsr-330-android-kotlin)

[![](https://blog.kotzilla.io/hs-fs/hubfs/Screenshot%202024-10-24%20at%2012.13.58.png?height=200&name=Screenshot%202024-10-24%20at%2012.13.58.png)](https://blog.kotzilla.io/why-migrate-from-dagger2/hilt-to-koin)

[Koin](https://blog.kotzilla.io/tag/koin), [Android](https://blog.kotzilla.io/tag/android), [Kotlin](https://blog.kotzilla.io/tag/kotlin), [Kotlin Multiplatform](https://blog.kotzilla.io/tag/kotlin-multiplatform), [KMP](https://blog.kotzilla.io/tag/kmp), [Cheat Sheet](https://blog.kotzilla.io/tag/cheat-sheet)

## [Why Migrate from Dagger2/Hilt to Koin?](https://blog.kotzilla.io/why-migrate-from-dagger2/hilt-to-koin)

[The Kotzilla Team](https://blog.kotzilla.io/author/the-kotzilla-team) 

 Oct 11, 2024, 11:13:51 AM

We’ve just wrapped up Koin’s very first webinar, and it was a great session, thanks to all those...

[Read more](https://blog.kotzilla.io/why-migrate-from-dagger2/hilt-to-koin)

facebook-f icon linkedin-in icon Twitter icon instagram icon

- Menu Item 1 
    - Sub-menu Item 1 
          - Another Item
    - Sub-menu Item 2
- Menu Item 2 
    - Yet Another Item
- Menu Item 3
- Menu Item 4

---

[![kotzilla-logo](https://blog.kotzilla.io/hubfs/kotzilla-logo.svg "kotzilla-logo")](http://www.kotzilla.io)

Copyright © 2025,

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "The Kotzilla Team",
    "url" : "https://blog.kotzilla.io/author/the-kotzilla-team"
  },
  "dateModified" : "2024-10-25T07:05:39.523Z",
  "datePublished" : "2024-10-17T13:44:50.000Z",
  "headline" : "Getting Started with Koin Annotations 1.4 in Compose Multiplatform",
  "image" : [ "https://blog.kotzilla.io/hubfs/Screenshot%202024-10-24%20at%2012.03.30.png" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.kotzilla.io/koin-annotations-1.4-in-compose-multiplatform",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.kotzilla.io/hubfs/__Kotzilla_format-site-web-line%201.png"
    },
    "name" : "Kotzilla SAS"
  }
}
```