Getting Started with Kotlin for Android Development
This article introduces Kotlin as a first‑class language for Android, explains why developers should adopt it, and provides a step‑by‑step guide to setting up Android Studio for Kotlin development, including plugin installation, project conversion, and configuration details.
Google today announced that Kotlin is now a first‑class programming language for Android development, and starting with Android Studio 3.0 it is bundled directly without requiring any additional plugins. Google is committed to advancing Kotlin‑related Android development tools to make building Android apps with Kotlin more efficient.
Kotlin was created by JetBrains last year and has become popular because it runs on the Java Virtual Machine and can be used together with Java to build applications. This means developers can reuse existing code and easily add new features or replace Java code. Since Kotlin depends on Java, both languages will continue to be supported.
Kotlin series articles will be released weekly by Hujiang Technical Academy; stay tuned.
Why Use Kotlin
If a programming language cannot change your way of thinking, it has failed. We are already proficient with static languages such as C, Objective‑C, and Java; it is time to learn Swift, Go, or Kotlin, which have syntax resembling dynamic languages.
Second, Kotlin can reduce a lot of boilerplate code and offers unique language features. Third, compared with Scala or Go, Kotlin is fully compatible with existing Java code, so frameworks we normally use such as Volley, KJFrameForAndroid, OKHttp continue to work under Kotlin.
IDE Selection
I prefer a hands‑on approach; this article first explains how to develop a Hello World Android app with Kotlin.
First, the IDE. Kotlin also supports Eclipse, but I will not cover it. Here we focus on Android Studio (3.0 preview already includes the Kotlin environment).
Development Environment Configuration
1. Launch Android Studio, open Preferences (Command+, on macOS; find the equivalent shortcut on Windows), search for plugins, click Browse Repository, search for Kotlin, and double‑click to install Kotlin and Kotlin Extension for Android. The first is the language support package, the second provides additional language features. In later versions Android Studio 2.0 merged the two plugins into one.
2. After installing the language support package, create a new Android project. Once the project is created, choose Code → Convert Java File to Kotlin File. The default shortcut is long, so I set it to Command+5 for convenience.
After conversion you will see that the original .java files have become .kt files.
3. Choose Tools → Kotlin → Configure Kotlin in Project. (Many older tutorials suggest manually editing build.gradle, but recent versions allow one‑click configuration in Android Studio.) Select the latest version, e.g., 0.12.613. You may see references to older versions such as M12 or M11, which correspond to these version numbers.
4. Click OK and wait while Android Studio downloads the necessary components (requires internet access). Once the download finishes, you can run the Android application.
The above steps complete the Kotlin for Android environment setup; the next article will cover Kotlin basic syntax and development tips.
Hujiang Technology
We focus on the real-world challenges developers face, delivering authentic, practical content and a direct platform for technical networking among developers.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.