Getting started with Android and Kotlin

Getting started with Android and Kotlin


This tutorial walks us through creating a simple Kotlin application for Android.

It’s extremely easy to start using Kotlin for Android development. In this tutorial we’ll follow the warming up process with Android Studio. If you're using Intellij IDEA with Android, the process is almost the same.

Creating a project

First, create a new Kotlin Android Project for your application:

  1. Open Android Studio and click Start a new Android Studio project on the welcome screen or File | New | New project.

  2. Select an activity that defines the behavior of your application. For your first "Hello world" application, select Empty Activity that just shows a screen, and click Next.

In the next dialog, provide the project details:

  • name and package
  • location
  • language: select Kotlin

Leave other options with their default values and click Finish.

Once you complete the steps, Android Studio creates a project. The project already contains all the code and resources for building an application that can run on your Android device or an emulator.

Building and running the application

The process of building and running the Kotlin application in Android Studio is exactly the same as with Java.

To build and run your application on an emulator:

  1. Run the predefined app configuration by clicking Run on the toolbar or Run | Run 'app'.
  2. Select Create New Virtual Device.

Select a device you like and click Next.

Select a system version and download its image.

  1. Verify the emulator configuration and click Finish.

  2. Click OK and here it is - your first Kotlin application for Android!

Kotlin has a rather small runtime file size: the library is approximately 1298 KB (as of 1.3.61). This means Kotlin adds just a little to .apk file size.

Kotlin compiler produces byte-code, thus there really is no difference in terms of look and feel of Kotlin applications versus those written in Java.

If you want to customize your builds or run configuration, refer to the Android Studio documentation

Source: kotlinlang

- Last updated 4 years ago

Be the first to leave a comment.

You must login to leave a comment