Android Setup & App Anatomy

This part requires Android Studio and either an emulator or a physical device. The example project lives in examples/android/.

Create a project

  1. Install Android Studio.
  2. New Project → Empty Activity (Compose).
  3. Set a package name (e.g. com.example.kotlinguide) and Kotlin as the language.
  4. Let Gradle sync finish.

Project anatomy

app/
├── build.gradle.kts             # module config: SDK versions, dependencies
├── src/main/
│   ├── AndroidManifest.xml      # components, permissions, app metadata
│   ├── kotlin/.../MainActivity.kt
│   └── res/                     # resources: strings, themes, drawables
│       └── values/
│           ├── strings.xml
│           └── themes.xml
build.gradle.kts                 # root build (plugin versions)
settings.gradle.kts              # modules + repositories
gradle/libs.versions.toml        # version catalog

Key files:

File Purpose
AndroidManifest.xml Declares activities, permissions, and the launcher entry point
build.gradle.kts (app) compileSdk, minSdk, dependencies, build features
res/ Strings, themes, images — referenced as R.string.app_name
MainActivity.kt The entry-point screen

Running

Pick a device in the toolbar (create an emulator via Device Manager if needed) and press Run (▶). Android Studio builds the APK, installs it, and launches the app.

From the command line (in examples/android/):

./gradlew :app:assembleDebug          # build the debug APK
./gradlew :app:installDebug           # install on a running device/emulator

assembleDebug and unit tests run in CI. Installing and instrumented (emulator) tests are run locally — they need a device.

The minimal app

The example’s MainActivity sets Compose content:

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme {
                Surface { CounterScreen() }
            }
        }
    }
}

We will unpack CounterScreen and setContent in the UI & Jetpack Compose chapter.

Exercises

  1. Create and run the Empty Activity project on an emulator.

  2. Change the launcher label in res/values/strings.xml and confirm it updates.


Next: Activity Lifecycle


Back to top

Kotlin & Android Programming Guide is not affiliated with JetBrains or Google. Content is provided for educational purposes.

This site uses Just the Docs, a documentation theme for Jekyll.