Quick take: Kotlin is Google's official first-class Android language as of 2019. New Android tutorials, codelabs, and Jetpack samples all default to Kotlin. The language gives you null-safety at compile time, data classes that remove a hundred lines of Java boilerplate per model, and full interop with existing Java libraries. Start with Android Studio, pick Kotlin in the new project wizard, and you're ready, started is covered here, with practical examples.
Kotlin became Google's recommended language for Android in May 2019. That means new sample code, new Codelabs, and the Jetpack libraries all ship Kotlin-first APIs. If you're starting fresh in 2026, there's no good reason to write a new Android app in Java unless your team explicitly refuses to learn anything else. This tutorial covers what you actually need: getting Android Studio installed, the Kotlin language basics that show up in every screen, and a working Hello World you can run on the emulator.
I've taught this material to backend engineers crossing over to mobile, and the same three things confuse them every time: the difference between val and var, the trailing ? on types, and why findViewById should be replaced with view binding. We'll hit all three.
Why Kotlin Instead of Java for Android?
The short answer: less code, fewer null bugs, and Google's own samples already use it. The longer answer is that Kotlin compiles to the same JVM bytecode Java does, so there's no performance cost. You get language features that Java doesn't have, the JetBrains compiler ships them, and you can call any existing Java library from Kotlin without thinking about it.
Here's the same data model written in both:
// Java - 30+ lines for a simple User model
public class User {
private final String name;
private final int age;
private final String email;
public User(String name, int age, String email) {
this.name = name;
this.age = age;
this.email = email;
}
public String getName() { return name; }
public int getAge() { return age; }
public String getEmail() { return email; }
@Override
public boolean equals(Object o) {
// ... 10 more lines
}
@Override
public int hashCode() {
// ... another 5 lines
}
}
// Kotlin - one line, same semantics
data class User(val name: String, val age: Int, val email: String)
That data class declaration gives you the constructor, getters, equals, hashCode, toString, and copy for free. Multiply this across an app with 40 data models and you're looking at a smaller codebase by thousands of lines. The Kotlin standard library docs cover the full list of what data class generates.
Null-safety is the other big win. In Java, any reference can be null and the compiler doesn't care. In Kotlin, String cannot be null and String? can, and the compiler enforces the difference. I've shipped Android apps where the only crashes left in Crashlytics came from third-party Java SDKs handing us null where their docs claimed they wouldn't.
How Do You Install Android Studio?
Download Android Studio from developer.android.com/studio. The 2025.1 release (Narwhal) is what I'd grab today. Run the installer, accept the SDK component defaults, and let it pull the latest Android 15 SDK plus build tools. The full install takes about 20 minutes on a fast connection and lands at roughly 8 GB.
A few choices worth making during first launch:
- Pick the standard install unless you already have an SDK directory you want to reuse
- Accept all license agreements (the SDK manager won't function until you do)
- Let the IDE download a default system image for the emulator (Pixel 7, API 34 is a sensible default)
Hardware-wise, you want at least 16 GB of RAM if you plan to run the emulator next to the IDE. The emulator itself is fine with 4 GB of RAM allocated, but Gradle and Android Studio together happily chew through another 6 to 8 GB. On older hardware, I run a physical device over USB instead, it's faster than the emulator anyway.
Creating Your First Project
In the New Project wizard, pick "Empty Activity", set the language to Kotlin, target a minimum SDK of 24 (covers about 95% of active Android devices per Google's distribution dashboard), and let the wizard generate a Gradle project. The default project structure puts your MainActivity.kt in app/src/main/java/com/yourname/yourapp/, even though the file is Kotlin, Android Studio keeps the directory name as java for historical reasons.
What Are the Kotlin Basics You'll Actually Use?
Three language features show up on every screen of an Android app: val/var, nullable types, and string templates. Get these into muscle memory and the rest of the language falls into place.
val and var
val name: String = "Alice" // read-only, like final in Java
var count: Int = 0 // mutable
count = count + 1 // OK
// name = "Bob" // compile error
// Type inference handles most cases
val message = "Hello" // inferred as String
var score = 100 // inferred as Int
Use val by default. The compiler will tell you when you need var because reassignment won't compile otherwise. In my experience, about 80% of declarations in a typical Android view model end up as val.
Nullable types and the safe call operator
var maybeName: String? = null // nullable
val definitelyName: String = "Alice" // non-null
// This won't compile - might be null
// val length = maybeName.length
// Safe call: returns null if maybeName is null
val length: Int? = maybeName?.length
// Elvis operator: provide a default
val safeLength: Int = maybeName?.length ?: 0
// Non-null assertion: throws if null (use sparingly)
val forced: Int = maybeName!!.length
The Elvis operator (?:) is the one I reach for most. It's the Kotlin equivalent of "use this if the left side is null".
String templates
val name = "Alice"
val age = 30
// Inline variables with $
val greeting = "Hello, $name, you are $age years old"
// Inline expressions with ${...}
val summary = "Next year, you'll be ${age + 1}"
No more String.format calls. Worth noting that single $variable works for plain names, but anything else needs the ${expression} form.
Functions and lambdas
// Top-level function
fun greet(name: String): String {
return "Hello, $name"
}
// Single-expression body, return type inferred
fun double(n: Int) = n * 2
// Lambda assigned to a variable
val square: (Int) -> Int = { n -> n * n }
// Lambda with implicit 'it' for single-arg
val triple: (Int) -> Int = { it * 3 }
Lambdas are everywhere in Android, every click listener, every coroutine, every collection transform. The it shortcut is one you'll see constantly.
How Do You Write a Hello World Activity?
Here's the smallest useful Android Kotlin activity, the one Android Studio generates for an Empty Activity project, with a TextView added programmatically.
package com.example.helloworld
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val greeting: TextView = findViewById(R.id.greeting_text)
greeting.text = "Hello, Kotlin on Android"
}
}
The matching activity_main.xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/greeting_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp" />
</LinearLayout>
Click the green run arrow, pick an emulator or USB device, and you'll see "Hello, Kotlin on Android" centered on the screen within about 30 seconds. The first build is slow because Gradle downloads dependencies, subsequent builds run in 5 to 10 seconds on a modern laptop.
One thing I'd flag: findViewById is fine for a tutorial, but in real projects you should switch to view binding (enabled in build.gradle.kts with viewBinding = true). That gives you compile-time-safe references to your views without the cast.
What Should You Learn Next?
The next stops after this introduction: layouts in XML (ConstraintLayout especially), the Activity lifecycle, and Jetpack Compose. Compose is the recommended UI toolkit for new projects in 2026, it replaces XML layouts with Kotlin code and integrates cleanly with the language features above. The Android Developers site has a "Now in Android" course that covers Compose in depth.
If your background is React or Vue, Compose will feel familiar, declarative UI driven by state. If your background is Java/Swing, the mental shift takes a week or two but pays off. Either way, don't skip past the Kotlin basics covered here, because every Compose function is a Kotlin function and every state value is a Kotlin object.
Related
- Android Introduction - the wider Android platform context, OS architecture, SDK/NDK, and project structure
- Button OnClick in Android Kotlin - the next step after Hello World, wire up button clicks with lambdas
- EditText with Toast in Android Kotlin - read user input, validate it, show feedback
- ImageView in Android Kotlin - display local and remote images with proper scaling and accessibility