Creating a Hello World App in Android Studio with Kotlin

8 months ago

Welcome to this tutorial on creating your first Android app using Android Studio and Kotlin. By the end of this guide, you'll have a simple "Hello World" app up and running on your Android device or emulator.


Before we begin, ensure you have the following:

  • Android Studio: Download and install Android Studio if you haven't already.
  • Kotlin Plugin: Android Studio comes with Kotlin support, so you don't need to install anything separately.
  • Android Device or Emulator: You can use a physical Android device or set up an emulator in Android Studio.

Step 1: Create a New Project

  1. Launch Android Studio.
  2. Click on "Start a new Android Studio project" or go to File > New > New Project.
  3. Choose a project template. For our "Hello World" app, select "Empty Activity," and then click "Next."
  4. Enter your app's name (e.g., "HelloWorldApp") and choose a package name. Click "Finish" to create the project.

Step 2: Write Kotlin Code

Now that you have your project set up, it's time to write the Kotlin code for the "Hello World" app. Follow these steps:

  1. Open the MainActivity.kt file located in the java > <your-package-name> > MainActivity.kt directory.
  2. You'll find an onCreate method. Replace the default code with the following:
package com.example.helloworldapp

    import android.os.Bundle
    import android.widget.TextView

    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {

            val textView = findViewById(
            textView.text = "Hello, World!"

This code sets the content view to your app's layout, finds a TextView with the id "textView," and sets its text to "Hello, World!".

Step 3: Design the Layout

To display the "Hello, World!" message, you need to create a layout. Follow these steps:

  1. Open the activity_main.xml file located in the res > layout > activity_main.xml directory.
  2. Delete the default TextView and replace it with the following:
        <?xml version="1.0" encoding="utf-8"?>
        <androidx.constraintlayout.widget.ConstraintLayout xmlns:android=""

                android:text="Hello, World!"
                app:layout_constraintTop_toTopOf="parent" />

This XML layout code defines a TextView with the id "textView" and sets its text to "Hello, World!".

Step 4: Run the App

Now it's time to run your app:

  1. Connect your Android device to your computer or start an emulator.
  2. Click the green "Run" button (or press Shift + F10) in Android Studio.
  3. Select your device from the list, and click "OK."

Your "Hello World" app should now appear on your Android device or emulator, displaying the message "Hello, World!"

Congratulations! You've successfully created a simple "Hello World" app in Android Studio using Kotlin. This is just the beginning of your Android app development journey. Explore more resources and tutorials to expand your skills and create more advanced applications.

Happy coding!