简体   繁体   中英

multiplatform or android platform alone and desktop alone for Kotlin

i am trying to make a project that is designed for a business and a customer where the business will be on the desktop side and the customer will be on the android side.

i was wondering since both the platforms will have unique UI(tabs/services/actions... etc.) that serves their needs:

should i use Kotlin multiplatform and use as much shared code as possible or build a standalone app that works separately on each platform and then share information by servers?

are there even other ways to accomplish my goal?

so far here are the most important pros and cons of multiplatform:

+reduce time consumed

+ability to share code which reduce bugs and possible errors.

  • still in alpha version (experimental) which means not enough libraries in support.

to be honest the only thing that is stopping me from choosing multiplatform is the "experimental " warning sign and if i chose to make desktop app alone might as well make android/IOS app altogether( since the sharing code ability between android and IOS is very much reliable) and in that way i would have gained an extra platform for my phone app in return for the added time of development

i really need an answer from any experienced Kotlin developer and thank you in advance:)

What the KMP thought for is sharing business logic between platforms.

If you have different business logic(business/customer sides) not sure how much you'll be able to share, but the least you can do is data objects: you can share same objects between business/client/server to make sure your json parsing is stable and doesn't require changes in many places.

You'll be able to share a lot of stuff if you choose to share android business logic with iOS, but note that there're some pitfalls you need to learn, so I'd say you'll spend 2x time for two platforms in first 1-3 month (same time as if you would do for two separate apps), and then your'll be able to make two apps with average speed of 1.5x time.

Don't forget that all UI part will take same time as for a separate app, so it won't be “free”

Still if your project is big enough, it should pay off.

What's about KMP being experimental: as for me it's already stable enough and I'm using it in my current project for sharing code between ios/android/server.

It's in active development phase so most of problems you face will be fixed fast, or you'll get a workaround on the youtrack

For the JVM part you almost loose nothing: you had to use Native frameworks but if you need to using jvm dependencies in the shared module, you had to provide alternative code for an each other platform(ios, etc) using expect / actual

It has some limitations for iOS platform. The main one, I think, is that you had to work with a specific memory model: you can't modify objects from different threads, but if you choose your architecture wisely it won't be a big problem.

I think your decision should depend on how much logic code you need to share between different platforms, and if there's a lot - KMP is a good solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM