I need help understanding how to create different application versions in the Kotlin Multiplatform project using the common codebase. In a ‘classic’ Android project I would create productFlavours e.g. applicationA
and applicationB
, appropriate sourceSet directories, and then put product-flavour-specific files in the source sets.
Every product flavor has its own Application
class, where different libraries are initialized, MainActivity
class, where a different navigation graph is created, and also own resource files (colors.xml
, settings.xml
), and in particular most important google-services.json
file for the configuration with a desired Firebase project.
How can I achieve the same result in the Kotlin Multiplatform project? Is it ever possible? If you have an idea how to resolve such a case I and many other people will be grateful for the detailed description.
2
Answers
This post might give you some ideas how to achieve "flavor" like functionality in multiplatform project. You can find there link to this example repository.
There is library BuildKonfig which lets you create BuildConfig file in multiplatform project.
This might help you to further customize your runtime.
To build you project just use:
One can as well define
productFlavors
inapp_android/build.gradle.kts
.This only works for Android, but one can at least cover different vendors.
There’s even a "Kotlin Multiplatform Wizard": https://kmp.jetbrains.com.