Skip to main content

Kotlin

Kotlin is a modern but already mature programming language designed to make developers happier. It's concise, safe, interoperable with Java and other languages, and provides many ways to reuse code between multiple platforms for productive programming.

To start using Kotlin for Android development, read Google's recommendation for getting started with Kotlin on Android.

Follow Kotlin on Twitter, Reddit, and Youtube, and don't miss any important ecosystem updates.

Kotlin for Android


Android mobile development has been Kotlin-first since Google I/O in 2019.

Over 50% of professional Android developers use Kotlin as their primary language, while only 30% use Java as their main language. 70% of developers whose primary language is Kotlin say that Kotlin makes them more productive.

Using Kotlin for Android development, you can benefit from:

  • Less code combined with greater readability. Spend less time writing your code and working to understand the code of others.

  • Fewer common errors. Apps built with Kotlin are 20% less likely to crash based on Google's internal data.

  • Kotlin support in Jetpack libraries. Jetpack Compose is Android's recommended modern toolkit for building native UI in Kotlin. KTX extensions add Kotlin language features, like coroutines, extension functions, lambdas, and named parameters to existing Android libraries.

  • Support for multiplatform development. Kotlin Multiplatform allows development for not only Android but also iOS, backend, and web applications. Some Jetpack libraries are already multiplatform. Compose Multiplatform, JetBrains' declarative UI framework based on Kotlin and Jetpack Compose, makes it possible to share UIs across platforms – iOS, Android, desktop, and web.

  • Mature language and environment. Since its creation in 2011, Kotlin has developed continuously, not only as a language but as a whole ecosystem with robust tooling. Now it's seamlessly integrated into Android Studio and is actively used by many companies for developing Android applications.

  • Interoperability with Java. You can use Kotlin along with the Java programming language in your applications without needing to migrate all your code to Kotlin.

  • Easy learning. Kotlin is very easy to learn, especially for Java developers.

  • Big community. Kotlin has great support and many contributions from the community, which is growing all over the world. Over 95% of the top thousand Android apps use Kotlin.

Many startups and Fortune 500 companies have already developed Android applications using Kotlin, see the list on the Google website for Android developers.

To start using Kotlin for Android development, read Google's documentation for developing Android apps with Kotlin.


Set up an environment

Before you create your first Kotlin Multiplatform application, you need to set up an environment for KMP development.

We recommend that you install the latest stable versions for compatibility and better performance.

ToolComments
Android StudioYou will use Android Studio to create your multiplatform applications and run them on simulated or hardware devices.
XcodeLaunch Xcode in a separate window to accept its license terms and allow it to perform some necessary initial tasks. Most of the time, Xcode will work in the background. You will use it to add Swift or Objective-C code to your iOS application.
JDKTo check whether Java is installed, run the following command in the Android Studio terminal or your command line: java -version
Kotlin Multiplatform pluginIn Android Studio, open Settings (Preferences) and find the Plugins page. Search the Marketplace tab for Kotlin Multiplatform, and then install it.
Kotlin pluginThe Kotlin plugin is bundled and automatically updated with each Android Studio release.

Check your environment

To make sure everything works as expected, install and run the KDoctor tool:

note

KDoctor works on macOS only. If you use a different operating system, skip this step.

  1. In the Android Studio terminal or your command-line tool, run the following command to install the tool using Homebrew:
brew install kdoctor

If you don't have Homebrew yet, install it or see the KDoctor README for other ways to install it.

  1. After the installation is completed, call KDoctor in the console:
kdoctor
  1. If KDoctor diagnoses any problems while checking your environment, review the output for issues and possible solutions:

    • Fix any failed checks ([x]). You can find problem descriptions and potential solutions after the * symbol.

    • Check the warnings ([!]) and successful messages ([v]). They may contain useful notes and tips, as well.

tip

You may ignore KDoctor's warnings regarding the CocoaPods installation. In your first project, you will use a different iOS framework distribution option.

FAQ

For dApp development using the Kotlin, we recommend referring to https://kotlinlang.org/docs/android-overview.html