Skip to content

TutorialBeginner

Your First Android Studio Project, Explained File by File

Create a new Compose project in Android Studio, run it on an emulator or your phone, and understand every file the template creates for you.

4 min read
Your First Android Studio Project, Explained File by File (cover)
On this page
  1. Before you begin
  2. Create the project
  3. What the template wrote for you
  4. Run it
  5. A tour of the project
  6. Your first change
  7. Where to go next

Opening Android Studio for the first time can feel like walking into a cockpit. Dozens of panels, a project full of files you did not write, and a build system downloading things in the background. The good news: every Android project has the same layout. Learn it once and you can find your way around any project.

In this tutorial you will create a project, run it on a virtual phone and on your own phone, and then take a tour of the files the template creates, so you know which ones you will actually touch.

Before you begin

You need Android Studio installed from the official Android Developers website. Copies from other sites can be outdated or unsafe. Google's install page lists 8 GB of RAM as the minimum and 16 GB if you plan to use the emulator, plus a 64-bit operating system. On Windows and Linux, the emulator also needs hardware virtualisation turned on.

Create the project

  1. On the Welcome screen, select New Project.
  2. Under Phone and Tablet, choose Empty Activity, then Next.
  3. Name it Hello Android. Android Studio fills in a package name such as com.example.helloandroid.
  4. Set Minimum SDK to API 24 (Android 7.0), which installs on the vast majority of phones in use. If you are asked for a build configuration language, keep Kotlin DSL.
  5. Select Finish and wait for Gradle to sync. The first sync can take several minutes while it downloads tools and libraries.

What the template wrote for you

When the sync finishes, Android Studio opens MainActivity.kt. Your version may differ by a line or two.

MainActivity.kt
class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge() // draw behind the status and navigation bars
        setContent { // everything inside is Compose UI
            HelloAndroidTheme { // your app's Material 3 colours and fonts
                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
                    Greeting(
                        name = "Android",
                        modifier = Modifier.padding(innerPadding)
                    )
                }
            }
        }
    }
}

@Composable
fun Greeting(name: String, modifier: Modifier = Modifier) {
    Text(text = "Hello $name!", modifier = modifier)
}

Three ideas are worth spotting straight away:

  • The activity is the entry point: Android starts it when someone taps your app's icon.
  • setContent hands the screen over to Compose.
  • Greeting is a composable function: a small piece of UI described in Kotlin.

Select Split at the top right of the editor to see the code and a live Preview side by side.

Run it

On the emulator

Open Device Manager, create a virtual device (a Pixel phone with a recent system image is a good choice), then pick it in the device list and select the green Run button. The first build is the slowest; after that, runs are much quicker.

If the emulator ever freezes, you do not need to reinstall anything. In Device Manager, Cold Boot restarts the virtual phone from off, and Wipe Data resets it to factory settings.

On your own phone

  1. On the phone, open Settings → About phone and tap Build number seven times until you see that you are now a developer.
  2. Open Developer options and turn on USB debugging.
  3. Connect the phone, allow debugging when asked, choose it in the device list and select Run.

A real phone is often faster than the emulator on a modest computer, and it shows how your app really feels in the hand.

A tour of the project

The Project panel starts in the Android view, which groups files by purpose. These are the ones that matter on day one.

What lives where
File or folderWhat it holdsOpen it to
manifests/AndroidManifest.xmlThe app's ID card for Android: screens, permissions, icon, themeAdd a permission or change the launcher screen
kotlin+java/…Your Kotlin code, including MainActivity.kt and the ui.theme packageWrite screens and logic
res/Resources: text, images, colours, iconsChange text, add images, translate
build.gradle.kts (Module :app)How to build your app: its id, Android versions and librariesChange minSdk or add a library
libs.versions.tomlThe version catalog: every library and plugin version in one placeAdd or update a dependency
settings.gradle.ktsThe project's modules and where libraries are downloaded fromAdd a module later

The manifest

Android reads AndroidManifest.xml before anything else. It lists your activities, the permissions you need and your app's icon and theme. The MAIN action and LAUNCHER category on MainActivity are what put your icon in the app drawer. A classic beginner error is loading data from the internet without declaring the permission:

AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />

Resources

Anything that is not code lives in res. Keep your text in res/values/strings.xml rather than typing it into Kotlin: add a translated copy in a folder such as values-es, and phones set to Spanish will show Spanish with no code changes.

Gradle: the builder

Gradle compiles your code, collects resources and libraries, and packages the app. The module's build file says how. Here is a shortened version; your numbers will be newer.

build.gradle.kts
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.compose)
}

android {
    namespace = "com.example.helloandroid"

    defaultConfig {
        applicationId = "com.example.helloandroid" // the app's unique id on Google Play
        minSdk = 24        // oldest Android version that can install it
        versionCode = 1    // goes up with every release
        versionName = "1.0" // the version people see
    }

    buildFeatures { compose = true }
}

dependencies {
    implementation(platform(libs.androidx.compose.bom)) // keeps Compose versions in step
    implementation(libs.androidx.material3)
}

The libs. names come from gradle/libs.versions.toml, the version catalog. Keeping every version in one file means a project with several modules never mixes library versions. After editing a Gradle file, select Sync Now in the bar at the top of the editor.

Your first change

Open res/values/strings.xml, change app_name to "My First App" and run the app again. Find it in the app drawer under its new name. Then change "Android" in MainActivity.kt to your own name and watch the Preview update. Small, safe changes like these are the fastest way to get comfortable.

Where to go next

Once the basics feel familiar, the real productivity gains come from knowing modern Android Studio well: version catalogs, the Compose BOM, KSP, Gemini in Android Studio, and a stock of Kotlin and Compose patterns you can reach for without searching.

That is what Learn Android Studio & Kotlin is for. It is our course for developers who know the basics and want to grow, with copy-ready Kotlin and Jetpack Compose code, complete apps explained file by file, and Android interview questions for every level. Every chapter ends with a Code recipes lesson: Kotlin examples by file, how they work, and real error messages with their fixes. The first three chapters are free.

Completely new to coding? Start with Learn Android App Development instead, which begins from zero.

  • #Android Studio
  • #Kotlin
  • #Jetpack Compose
  • #Gradle

Keep reading