Hi :wave: How to migrate existing Android kotlin...
# multiplatform
r
Hi ๐Ÿ‘‹ How to migrate existing Android kotlin application to kotlin multi-platform? Any iterative steps? When I tried in Android studio, kotlin multi platform template is not visible even KMP mobile plugin is installed. The same happened in Mac as well as windows. Am I missing anything here? Thanks in advance!
j
@Raja Appapurapu Take a look at this https://stackoverflow.com/questions/71510247/how-to-convert-kotlin-project-to-kotlin-multiplatform-mobile-after-the-project-c Note that some libraries might already support Kotlin Multiplatform, so no changes are needed. I would personally recommend starting a fresh project and move the code in bits e.g if you have Room Db then you'll need to rewrite the logic with Ktor and SQLDelight.
j
I recommend this guide: https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-integrate-in-existing-app.html#make-your-code-cross-platform First of all, define what you want to migrate before migrating is my recommendation ๐Ÿ™‚ Like can you start off with small pieces or need to be big bang. You can do phased migration and mix ๐Ÿ™‚
r
Thanks for the updates. I shall give a try and update.
c
I'm currently following that link above to try to convert a medium-sized Android app into iOS.
I've also been making use of kmp.jetbrains.com
I did do a few things as prerequisites. Like moving two version catalogs and using KTS files instead of groovy files
j
Also if you have convention plugins, the migration goes a lot easier, to add KMP/CMP plugins into existing Android gradle modules ๐Ÿ™‚ You dont need to have, but it makes thing much easier to re-use across multiple setups required. Like some flags in shared modules or Kotlin native targets etc.
r
Just created the simple android application and looking to migrate to kmp. Also, installed the kotlin multiplatform plugin. This is what I am facing the problem as my android studio, is not showing this kmp template -
j
Go to http://kmp.jetbrains.com/, generate project from that, open in Android Studio ๐Ÿ™‚ I dont think Android Studio yet supports generating this, but I am uncertain. I think the shared module thing you selecting is something else you would like?
r
Ohh okay Thanks. So created http://kmp.jetbrains.com/ to download and add it as new module (shared) to existing android application Correct?
j
Yeah kind a, but easier use as it is and copy the code from your existing android app instead ๐Ÿ™‚
r
Okay thanks. This is good as soon as application is simple. But real Android applications are very big and kotlin, c++ and libraries included. Seems need more deep dive. Thanks for the advice.
c
r
Thanks. Thats the catch. by default kotlin experimental is disabled. KMP template appeared after enabling an experimental flag in Android Studio -> advanced settings -> kotlin experimental -> Enable.
213 Views