Chapter 9: Koin, Application, and MainActivity

I just started working through the book last week as a way to work on a new project I’ve started (cross-platform iOS, Android, and desktop) with the goal of focusing on Android first and then extending to the other platforms.

The issue I’m hitting is when trying to incorporate Koin into that codebase. Specifically, our initial code was generated using the Kotlin Multiplatform Wizard [1]. The code generated there doesn’t include any class that extends Application.

My question is: how do I add such a class to my project so I can initialize Koin and use DI? I know this isn’t directly related to the book, except to ask how to adapt its content to my project.

[1] https://kmp.jetbrains.com/

If you’re talking about the Android Application class, just create a new file/class and extend the Application class. Then open the AndroidManifest.xml and add:

       android:name=".<AppName>"
2 Likes

Sorry to reply late: that worked for me. Thank you!