Project Setup

Personal Catalogue: Android (Kotlin & Compose)

Course 1 · Chapter 1 · The App and the Empty Project

This course builds a real app for your own phone: a catalogue of the books, CDs, DVDs and Blu-rays you own, so that standing in a shop you can answer "do I already have this?" in a few seconds. You may already have built it for the web with PHP, Django, Express or Firebase. This is the same app, rebuilt as a native Android app in Kotlin with Jetpack Compose for the screens and Room for the database. A sister course, Personal Catalogue: iOS (Swift & SwiftUI), builds exactly the same app with the same chapter order, so you can follow either one, or both side by side.

What was run, and what was not
Nothing in this chapter was run. The machine this course is written on has no Android Studio and no emulator. The steps and code come from my knowledge of Android Studio and from Google's developer documentation, and I checked only what the search results at the end of the chapter actually say. The wizard's wording, the default minSdk and the exact version numbers change with every Android Studio release, so wherever this chapter names one, trust what your own Android Studio shows over the text here, and treat the code as a starting point to compile, not as something already proven to build.
Updated 2026-11-21: the wizard screens and the generated project described below were checked against screenshots and files from a real Android Studio Rabbit 2 install (the Not Yet Verified box at the end says exactly what). The chapter's code has still not been compiled by me.

What We Are Building

The app has one job and a short list of features. Everything in this course is taken from the shared spec that both mobile courses use:

ChapterFeature added
1The empty project, package layout, first screen on the emulator
2–3The data model and the Room database, seeded with the four item types
4–5The list screen and the detail screen, with navigation between them
6One add/edit form whose labels change with the item type
7Tags: a managed, reusable list, with autocomplete
8Search by title or creator, filter by tag
9Duplicate warning, dark theme, accessibility, error states
10JSON backup and restore, tests, and what to build next

The data model is small. An item has a title, a creator (author, artist or director), a "format detail" (hardcover, album, region code and so on), an optional year and some notes. Every item has one type (Book, CD, DVD or Blu-ray) and any number of tags. The app is for one person, stores everything on the phone and works with no network. Barcode scanning, cover art and cloud sync are deliberately not in this course: they are listed in the spec as later features, and a later course can add them.

How This Differs from the Web Versions

If you built a web catalogue, most of the thinking carries over and only the machinery changes. This table shows where each web idea lands on Android:

Web catalogue (Django, PHP, Express)This course
LanguagePython, PHP or JavaScriptKotlin
ScreensHTML templates or React componentsComposable functions (Jetpack Compose)
DatabasePostgreSQL, MySQL, MongoDB or Firestore on a serverRoom, a layer over SQLite, on the phone
Data entryDjango admin or an HTML formA Compose form screen
ServerNeeded (Gunicorn, Apache, Node and so on)None: the app is the whole system
Running itA browser pointed at a URLThe Android Emulator, or your own phone
UpdatesDeploy and everyone sees themInstall a new build; data lives on that one phone

The big consequence is the last two rows. There is no server and no login, so the app is simpler to run but the data lives on one device. That is why Chapter 10 builds a backup file: it is the Android equivalent of the database dump you would take from a web version.

Creating the Project

You need Android Studio installed. The Android Development: Fundamentals course and Android Studio: The IDE Itself cover installing it, so this chapter does not repeat that. To create the project, per Google's documentation:

  1. Choose File > New > New Project (or New Project from the welcome screen).
  2. In the template window choose Empty Activity and click Next. Older guides call this template Empty Compose Activity (Material3); check the name your version shows. In Rabbit 2 the category is Phone and large screens; the XML-based templates are labelled Views (Basic, Empty and Responsive Views Activity), so Empty Activity is the Compose one.
  3. Set Name to Catalogue. Set Package name to a package you own; this course uses com.example.catalogue in its examples, which you should replace with your own if you ever publish the app.
  4. Choose a save location, and keep spaces out of the whole path: the wizard warns that whitespace in the save location can cause problems with the NDK tools (native code), which this app does not use but a later project might. There is no Language or Build configuration language field for this template: it generates Kotlin and the Kotlin DSL for you.
  5. Pick a minimum SDK from the drop-down. The right choice is a trade-off (older versions reach more phones, newer ones give you more built-in features). In Rabbit 2 the wizard proposes API 24 ("Nougat"; Android 7.0) and shows that the app will run on approximately 99.5% of devices; a Help me choose link explains the trade-off. Accept the default your own Android Studio proposes and write the number down: later chapters mention it where it matters.
  6. Click Finish and wait for the first Gradle sync to complete. The first sync downloads libraries and can take several minutes.

What the Wizard Generated

A new project is mostly Gradle configuration plus one activity. These are the parts you will actually touch in this course, in the Project view of the Project tool window:

Catalogue/ ├── app/ │ ├── build.gradle.kts <- this module's dependencies (Room goes here in Chapter 3) │ └── src/ │ └── main/ │ ├── AndroidManifest.xml <- declares the app and its one activity │ ├── java/com/example/catalogue/ │ │ ├── MainActivity.kt <- the entry point │ │ └── ui/theme/ <- Color.kt, Theme.kt, Type.kt (Material 3 theme) │ └── res/ <- strings, icons, themes ├── gradle/ │ └── libs.versions.toml <- version catalog: one place for library versions ├── build.gradle.kts <- project-level plugins └── settings.gradle.kts <- which modules the build includes

Your project also contains a few files this course does not touch: example tests in app/src/test and app/src/androidTest, a keepRules folder with a rules.keep file for the release-build shrinker, and two small XML files in res/xml about app backup. Leave them as generated.

Two files matter more than the rest. MainActivity.kt is where the app starts. libs.versions.toml is the version catalog: the generated build files read library names and versions from it, so when a later chapter adds Room you add a line there and a line in app/build.gradle.kts. Compose libraries are normally kept in step with each other through a Compose BOM (a "bill of materials" that fixes one compatible version for the whole Compose family), which is why the generated Compose dependencies do not each carry their own version number. Google's setup page lists Material 3 as androidx.compose.material3:material3; check your generated file for the exact lines and versions.

A Package Layout for the Whole Course

The wizard puts everything in one package. For a small app that is fine, but this one grows through ten chapters, so decide the layout now. The folders are by responsibility, not by screen type, which is the same split the web versions made between models, views and templates:

com.example.catalogue/ ├── MainActivity.kt ├── data/ <- Room entities, DAOs, database, repository (Chapters 2-3) ├── ui/ │ ├── theme/ <- generated by the wizard │ ├── list/ <- list screen + view model (Chapter 4) │ ├── detail/ <- detail screen + view model (Chapter 5) │ ├── form/ <- add/edit screen + view model (Chapter 6) │ └── navigation/ <- the route table (Chapter 5) └── backup/ <- JSON export and import (Chapter 10)

In Android Studio, switch the Project tool window to the Android view, right-click the com.example.catalogue package and choose New > Package for each of data, ui.list, ui.detail, ui.form, ui.navigation and backup. Empty packages are not shown until they hold a file, so each will appear once you add its first class in a later chapter. Creating them now is optional; the point is to know where each thing will go.

A First Screen of Our Own

Replace the generated greeting with a screen that says what the app is. The code below is a sketch of the usual shape of a generated Compose activity: an activity that calls setContent, which wraps a screen in the generated theme. Your generated file will differ in small ways (for example it calls enableEdgeToEdge() and includes a preview function); keep what the wizard gave you and change only the composable it displays. Two things then need doing by hand. First, imports: the wizard's import list does not include every name the sketch uses, so Box, Alignment and MaterialTheme will show in red until you click each one and press Alt+Enter and choose Import (or paste the sketch's import lines). Second, the preview: the generated @Preview function still calls Greeting("Android"), which no longer exists once you replace the greeting, so change that call to CatalogueApp(). Until both are done the file will not compile.

package com.example.catalogue import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import com.example.catalogue.ui.theme.CatalogueTheme class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { CatalogueTheme { CatalogueApp() } } } } // The app's root composable. Later chapters replace the body with navigation. @Composable fun CatalogueApp() { Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> Box( modifier = Modifier .fillMaxSize() .padding(innerPadding), contentAlignment = Alignment.Center ) { Text( text = "My Catalogue", style = MaterialTheme.typography.headlineMedium ) } } }

Three ideas in that file carry the whole course. A composable is a Kotlin function marked @Composable that describes some UI; Compose calls it again whenever the data it shows changes. A Scaffold is Material 3's standard screen frame (later it holds the top bar and a "+" button) and hands your content an innerPadding so that it does not sit underneath system bars. A Modifier is how you size, pad and align a composable: you chain them, and the order matters (here, fill the screen, then pad it).

Running It

  1. Open Tools > Device Manager and create a virtual device (a recent Pixel phone image is a good default). Download the system image if Android Studio offers to.
  2. Choose the device from the toolbar drop-down and press Run (the green triangle). The first build is slow; later ones are much faster.
  3. When the emulator shows My Catalogue in the middle of the screen, you have a working toolchain.

To run on your own phone instead, turn on Developer options and USB debugging on the phone, connect it by cable, and it appears in the same drop-down. If the build fails, the Build tool window shows the first error at the top; fix that one first, since later errors often cascade from it.

Compare with the iOS course
In Personal Catalogue: iOS (Swift & SwiftUI) Chapter 1 does the same job: a new Xcode project, a folder layout, and a first screen. The mapping is direct: a composable function is a SwiftUI View, a Scaffold is roughly a NavigationStack with a toolbar, and the Android Emulator is the iOS Simulator. The two apps will end up with the same screens and the same data model.

Challenges

Exercise 1

Create the project exactly as described and run it on the emulator. Write down the Name, Package name, minimum SDK and the name of the template your Android Studio showed. Then find minSdk in the generated app/build.gradle.kts (or the version catalog) and confirm it matches the number you chose.

📄 View solution
Exercise 2

Change the screen so that it shows the app name in the centre and, underneath it, a second, smaller line: "Books, CDs, DVDs and Blu-rays". You will need a Column inside the Box. Run it and say which Modifier or alignment argument controls the gap between the two lines.

📄 View solution
Exercise 3

Open the web catalogue course you finished (any of the four) and list, for each of the seven rows in the comparison table in this chapter, the exact file or tool you used there. Then pick the one row where Android makes your life easier and the one where it makes it harder, and explain each in a sentence.

📄 View solution

Chapter 1 Quick Reference

  • The app: single-user, offline catalogue of books, CDs, DVDs and Blu-rays; items have a type, a creator, a format detail, an optional year, notes and tags
  • Stack: Kotlin, Jetpack Compose with Material 3, Room, ViewModel with StateFlow, Navigation Compose
  • New project: File > New > New Project > Empty Activity (Compose); no spaces in the save location; Kotlin and Kotlin DSL are automatic; accept the default minimum SDK (API 24 in Rabbit 2) and record it
  • Version catalog: gradle/libs.versions.toml; app dependencies: app/build.gradle.kts; Compose versions are kept together by a BOM
  • Package layout: data, ui.list, ui.detail, ui.form, ui.navigation, backup, plus the generated ui.theme
  • A composable is a @Composable function that describes UI; Scaffold is the screen frame; Modifier chains size, padding and alignment
  • Run: Device Manager, create a virtual device, press Run; or use a phone with USB debugging
Not Yet Verified
Checked (one web search on 2026-11-19): Google's steps to start a project (File > New > New Project, then Empty Activity); that Material 3 is the artifact androidx.compose.material3:material3; that current docs call the template "Empty Activity" while older guides say "Empty Compose Activity (Material3)"; and that Compose uses a BOM. The search did not confirm the wizard's default minimum SDK; the screenshots below did.
Checked on a real Android Studio Rabbit 2 (2026-11-21, from the reader's screenshots and project files): the template list and the Views labels; the two wizard pages and their fields (Name, Package name, Save location, Minimum SDK, no Language or build configuration field for Empty Activity); the default minimum SDK of API 24 and the whitespace warning; that the generated project uses the Kotlin DSL and a version catalog with a Compose BOM; the generated file tree (plus the extra test, keepRules and backup files); that MainActivity.kt calls enableEdgeToEdge() and generates a preview that calls Greeting; and that Device Manager is under Tools and in the right-hand tool window bar.
Not checked, from general knowledge: that the sketch compiles once the imports and the preview are fixed (it was never built; CatalogueTheme is derived from the project name); the USB debugging steps; the package layout (a design choice, not a platform rule); and the comparison with the iOS course. Compile it, and correct anything your Android Studio does differently.
Sources for This Chapter
Search results (2026-11-19): Android Developers, Set up the Compose Compiler Gradle plugin; Android Developers, Compose setup. Only the titles and short summaries in the search results were used.
Coming next
Personal Catalogue: Android (Kotlin & Compose) 2 designs the data model: the ItemType, Item and Tag entities as Room classes, the many-to-many link between items and tags, and why the same decisions you made for the Django models apply here.