Kotlin (and MVVM) Everywhere!

We Love Kotlin and JVM!

Our January post about the importance of proper MVVM for Kotlin explained why the Kotlin language is important.

Now it is time to stress the cross-platform nature of the sample project. With kt-mvvm-demo you write your application once and deploy it to desktop, Android, iOS and browser with the help of portable DukeScript presenters.


The sample project comes with classical Android Gradle installDebug task to package your application as an Android .apk file and deploy it to your device or simulator:

$ ANDROID_HOME=/android-sdk/ ./gradlew installDebug
$ ls app/build/outputs/apk/

Kt-Mvvm-Demo on Android


One can package the same code as an iOS .ipa file with the help of Intel’s Multi OS Engine when running on Mac OS X. First of all list your simulators and then use one of them to launch your application:

$ ./gradlew moeListSimulators
- DD9904B6-76CD-4F2D-9153-EC7182878897 - iOS 11.4 - iPhone X
$ ./gradlew moeLaunch -Pmoe.launcher.simulators=DD9904B6-76CD-4F2D-9153-EC7182878897

Kt-Mvvm-Demo on iOS


The same application can also be transpiled to JavaScript and executed in the browser. The bck2brwsrShow tasks generates necessary .js files and launches a browser with the application

$ ./gradlew bck2brwsrShow
Showing http://localhost:53241/index.html
$ ls -l web/build/web/

The files in web/build/web directory contain everything needed to execute your application and as such they can be deployed to any HTTP server as a static content. Read more.

Kt-Mvvm-Demo in the browser

With Kotlin MVVM API you can write your code once, deploy and display it everywhere (desktop - gradlew run, Android - gradlew installDebug, iOS - gradlew moeLaunch, browser - gradlew bck2brwsrShow) while using the power of Kotlin, its libraries and any other JVM libraries on every target platform.

The JVM Portability

The fact that one can execute the same Kotlin application on all the above platforms is not like the traditional Kotlin.js and Kotlin.native portability. With Kotlin.xxx one only gets the portability of the Kotlin language, but not the libraries.

With the kt-mvvm-demo project you may bring with yourself JVM libraries - e.g. JARs - from your previous life (e.g. written in Java & other JVM languages) that otherwise can’t go with you to the Kotlin js and native worlds.

We love Kotlin on the JVM!