Introduction

Welcome to your first Android application! In this tutorial, we’ll walk through creating a simple “Hello World” app in Android Studio. This is the foundation for all Android development and will introduce you to the basic structure of an Android project.

Prerequisites

Before starting this tutorial, make sure you have:

Video Tutorial

Follow along with this step-by-step video guide:

infoWatch the video for a complete walkthrough, then use the written instructions below as a reference!

Creating a New Project

Launch Android Studio

  1. Open Android Studio
  2. From the welcome screen, click New Project
  3. If you already have a project open, go to FileNewNew Project

Select Project Template

  1. In the “New Project” window, select Empty Views Activity
  2. Click Next

infoThe Empty Views Activity template provides a basic activity with an XML layout and minimal code, perfect for learning. Note: the template named Empty Activity now creates a Kotlin/Jetpack Compose project instead.

Configure Your Project

Fill in the following details:

  • Name: HelloWorld
  • Package name: com.example.helloworld
  • Save location: Choose your preferred directory
  • Language: Java or Kotlin (your choice)
  • Minimum SDK: API 21 (Android 5.0)

Click Finish when done.

Wait for Gradle Build

Android Studio will now:

  1. Create your project structure
  2. Download necessary dependencies
  3. Build your project

This may take a few minutes on first run.

Understanding the Project Structure

Key Files and Folders

Project Components

  • app/src/main/java/ - Contains your Java/Kotlin code
  • app/src/main/res/ - Contains all resources (layouts, images, strings)
  • app/src/main/AndroidManifest.xml - App configuration and permissions
  • build.gradle - Build configuration files

MainActivity

// Java version
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}
// Kotlin version
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

Layout XML

<?xml version="1.0" encoding="utf-8"?>
<!-- activity_main.xml -->
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textSize="24sp" />

</androidx.constraintlayout.widget.ConstraintLayout>

Running Your App

Select Your Device

  1. Click the device dropdown in the toolbar
  2. Select your virtual device or connected physical device

Run the Application

  1. Click the Run button (green play icon) or press Shift + F10 (Windows/Linux) or Ctrl + R (macOS)
  2. Wait for the app to build and deploy
  3. The app will launch on your selected device

View the Result

You should see “Hello World!” displayed on the screen!

Customizing Your Hello World App

Changing the Text

Open the Layout File

  1. In the Project window, navigate to app/src/main/res/layout/
  2. Double-click activity_main.xml to open it
  3. At the top-right of the editor, switch to Code view (or Split view to see the code and design preview side by side)

Edit the TextView Directly

Find the TextView element and change the value of the android:text attribute:

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello, Android Development!"
    android:textSize="24sp" />

Re-run the app to see your new text on the screen.

errorHardcoding text directly in the layout works, but Android Studio will show a lint warning. The recommended approach is to use a string resource — see the next step.

  1. Open app/src/main/res/values/strings.xml
  2. Add a new string entry:
<resources>
    <string name="app_name">HelloWorld</string>
    <string name="greeting">Hello, Android Development!</string>
</resources>
  1. Back in activity_main.xml, reference the resource instead of hardcoding the text:
<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/greeting"
    android:textSize="24sp" />
  1. Run the app again — the text comes from your string resource

infoKeeping all user-facing text in strings.xml makes your app easier to maintain and is required for supporting multiple languages later.

Adding Colors

Define Colors in colors.xml

  1. In the Project window, navigate to app/src/main/res/values/
  2. Open colors.xml (create it via right-click → NewValues Resource File if it doesn’t exist)
  3. Add your custom colors as hex values:
<resources>
    <color name="my_text_color">#1565C0</color>
    <color name="my_background_color">#FFF9C4</color>
</resources>

infoColors use hex format: #RRGGBB, or #AARRGGBB if you want transparency (alpha). Android Studio shows a color swatch in the editor gutter — click it to open a color picker.

Apply Colors in the Layout

Open activity_main.xml and use android:textColor on the TextView and android:background on the root layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/my_background_color">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/greeting"
        android:textColor="@color/my_text_color"
        android:textSize="24sp" />

</androidx.constraintlayout.widget.ConstraintLayout>

Run and Verify

  1. Run the app again (Shift + F10 on Windows/Linux, Ctrl + R on macOS)
  2. You should see your custom text in your chosen color on the new background color

infoJust like strings, defining colors in colors.xml instead of hardcoding hex values in layouts keeps your theme consistent and easy to change in one place.

Common Issues and Solutions

Next Steps

After completing your first Hello World app, you can:

  1. Modify the UI - Change colors, fonts, and layouts
  2. Add user interaction - Implement buttons and click listeners
  3. Learn about Activities - Understand the Android lifecycle
  4. Explore Views and Layouts - Build more complex interfaces
  5. Add tests - Add tests for your code

Additional Resources


infoPractice by creating variations of this app - try different text, colors, and layouts to get comfortable with Android Studio!