Mehdi TmimiMobile DevelopmentMobile

Mobile Development Lab 2 Part 0 · at home

Before class: read Kotlin, create the project

The first build of a Compose project downloads its libraries: do it at home, not on the class Wi-Fi.

  • You finished Lab 1: Android Studio, the Pixel 7 phone and your package name are ready.

Tested with Android Studio Rabbit 2 (2026.2.2) and the Android 17 emulator (API 37), November 2026.

The idea

Two projects, one app on the phone

The phone knows an app by its applicationId, not by its folder or its language. Lab 2 keeps Lab 1’s: its Notes replaces Lab 1’s, and each part shows Lab 1’s screen beside the new one.

Lab 2, as the wizard writes it

Gradle Scripts › build.gradle.kts (Module :app)Read only
plugins {    alias(libs.plugins.android.application)    alias(libs.plugins.kotlin.compose)}
android { namespace = "com.yourname.notes" compileSdk { version = release(37) }
defaultConfig { applicationId = "com.yourname.notes" minSdk = 24 targetSdk = 37 versionCode = 1 versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" }
buildTypes { release { optimization { enable = true packageScope = setOf("androidx.**", "kotlin.**", "kotlinx.**") } } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } buildFeatures { compose = true }}
dependencies { implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.activity.compose) implementation(libs.androidx.compose.material3) implementation(libs.androidx.compose.ui) implementation(libs.androidx.compose.ui.graphics) implementation(libs.androidx.compose.ui.tooling.preview) implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) testImplementation(libs.junit) androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.compose.ui.test.junit4) androidTestImplementation(libs.androidx.espresso.core) androidTestImplementation(libs.androidx.junit) debugImplementation(libs.androidx.compose.ui.test.manifest) debugImplementation(libs.androidx.compose.ui.tooling)}
  1. namespace: the package of your Kotlin code.
  2. applicationId: the app’s name on the phone, the same as in Lab 1.

On the phone, at step 0.4

Lab 1’s Notes on the phone: the gradient header, the composer and three pastel note cards.
Lab 1’s Notes
Lab 2’s first run in its place: “Hello Android!” at the top left of a white screen.
Lab 2 replaces it
  • applicationId the same: one Notes icon on the phone, Lab 2’s.
Lab 1 The same two lines 1 min
Gradle Scripts › build.gradle.kts (Module :app)Read only
plugins {    alias(libs.plugins.android.application)}
android { namespace = "com.yourname.notes" compileSdk { version = release(37) }
defaultConfig { applicationId = "com.yourname.notes" minSdk = 24 targetSdk = 37 versionCode = 1 versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" }
buildTypes { release { optimization { enable = true packageScope = setOf("androidx.**", "kotlin.**", "kotlinx.**") } } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 }}
dependencies { implementation(libs.appcompat) implementation(libs.material) implementation("androidx.constraintlayout:constraintlayout:2.2.2") testImplementation(libs.junit) androidTestImplementation(libs.espresso.core) androidTestImplementation(libs.ext.junit)}

Lab 1’s build.gradle.kts holds the same two values. Only the folder differs: Notes for Lab 1, NotesCompose for Lab 2.

Before you start

By the end you can

  • read a line of Kotlin beside the Java you know;
  • create a Compose project with Empty Activity, under Lab 1’s package;
  • run it: “Hello Android!” replaces Lab 1’s Notes on the phone.
  • At home the Kotlin sheet
  • Android Studio Welcome · New Project
  • Emulator Running Devices
On a Mac What changes 1 min
  • Cmd replaces Ctrl, and Option+Enter replaces Alt+Enter.
  • The project folder is ~/AndroidStudioProjects/NotesCompose.
  • The rest is the same. This page is tested on Windows only.

Step 1 of 4

Read the Kotlin sheet

10 min

Goal Read the ten cards once: each puts a Kotlin line beside the Java you already know.

  • At home your browser
  1. The sheet, open in a tab of its own.

    1. Open Read Kotlin in ten minutes: it opens in a new tab.
    2. Read its four rules at the top, then its ten cards, in order.
    3. Card 8, { } after the call, is the one every screen of Lab 2 uses: read it twice.
    4. Keep the tab: each part links to the card a new line needs.

Why You do not write Kotlin from memory in Lab 2: you read it, then type short lines the sheet explains.

Step 2 of 4

Start a project with Empty Activity

5 min

Goal Start from Empty Activity, the template that writes a Compose screen: in Lab 1 you chose No Activity.

  • Android Studio Welcome · New Project
  1. A new project, from the Compose template.

    1. Android Studio opens on Lab 1’s Notes? Click FileClose Project: the Welcome window opens.
    2. In the Welcome window, click New Project.
    3. A New Project window opens: click Phone and large screens, in the list on the left.
    4. Click Empty Activity, selected by default. Not Empty Views Activity, and not No Activity.
    5. Click Next: the form of step 0.3 opens.
    New Project A dialogFull size
    The New Project window: Phone and large screens selected on the left; the tiles No Activity, Empty Activity (selected), Gemini API, then Navigation UI Activity, Basic Views Activity and Empty Views Activity.
    1. Phone and large screens: the category.
    2. Empty Activity: the Compose template, the one to keep.
    3. No Activity: Lab 1’s template, no screen at all.
    4. Empty Views Activity: a screen in XML, not Compose.
Stuck? 2 symptoms
  • No Close Project in the File menu Use FileNewNew Project instead: the same window opens, and the project opens in a new window.
  • You chose Empty Views Activity It writes an XML layout, as in Lab 1. Delete the project’s folder, then start again with Empty Activity.

No project file yet: the next step writes them.

Step 3 of 4

Fill in the form, keep Lab 1’s package

10 min

Goal Create Notes in Compose, with Lab 1’s package, in the folder NotesCompose.

  • Android Studio New Project › Empty Activity
  1. Your package name, the one of Lab 1.

    1. The field below shows the package this browser kept from Lab 1. Empty? Type yours: com.yourname.notes.

    Without JavaScript, the code says com.yourname.notes: replace yourname by the name you chose.

  2. The form: Notes, your package, NotesCompose, API 24.

    1. The page Empty Activity opens. In Name, select the text with Ctrl+A, then type Notes.
    2. Package name becomes com.….notes: it must be the package in the field above. If not, select it with Ctrl+A, then type it: com.yourname.notes.
    3. Save location ends in Notes2, since Lab 1’s Notes exists: change Notes2 to NotesCompose.
    4. In Minimum SDK, keep API 24 (Android 7.0).
    5. Click Finish.
    New Project › Empty Activity A dialogFull size
    The Empty Activity form, “Create a new empty activity with Jetpack Compose”: Name Notes, Package name com.yourname.notes, Save location C:\Users\PC\AndroidStudioProjects\NotesCompose, Minimum SDK API 24 (“Nougat”; Android 7.0).
    1. Package name: com.yourname.notes, Lab 1’s.
    2. Save location: …\AndroidStudioProjects\NotesCompose.
    3. Minimum SDK: API 24 (Android 7.0).
  3. Android Studio, open on NotesCompose.

    1. The project opens on MainActivity.kt and syncs by itself: wait 1 to 2 minutes, until the progress bar at the bottom right is gone.
    2. A balloon says Kotlin version 2.4.0 is available: ignore it, and every other version update.
    3. A balloon, Microsoft Defender may affect IDE, may appear: ignore it.

Why Keep Notes exactly: the theme is then NotesTheme, as in the code you paste later. The lab is built on the versions the wizard writes: keep them.

Done I see MainActivity.kt open, and app and Gradle Scripts in the Project window.

Stuck? 3 symptoms
  • The package is not Lab 1’s (….notes.compose, another name) It still works, beside Lab 1: two Notes on the phone. Type that package in the field above, so each page’s code uses it.
  • The folder stayed Notes2 It works too. The pages say NotesCompose: your project is in Notes2.
  • The sync fails, or never ends The first sync downloads the Compose libraries. Connect to the Internet, then click FileSync Project with Gradle Files.

No file of yours yet: the wizard wrote the whole project. Part 1 shows you around it.

Step 4 of 4

Run it once

5 min

Goal Run the template on the Pixel 7: “Hello Android!” takes the place of Lab 1’s Notes.

  • Android Studio Device Manager · Run
  • Emulator Running Devices
  1. The phone, inside the project.

    1. Click Device Manager, its icon on the window’s right edge.
    2. Click ▶ on the Pixel 7 row.
    3. The phone opens in Running Devices: wait for its home screen.
  2. The template, built and on the phone.

    1. Click Run 'app' in the toolbar, or press Shift+F10.
    2. The first build takes a few minutes. Then the app opens on the phone.

Why Same applicationId as Lab 1: Android installs Lab 2 over it. Lab 1’s project stays on your disk.

The Pixel 7 running the Empty Activity template: “Hello Android!” in small black letters at the top left of a white screen, just under the status bar.

You should see “Hello Android!” in small letters at the top left, on white, just under the status bar.

Done I see “Hello Android!” on the phone.

Stuck? 3 symptoms
  • “Installation did not succeed … signatures do not match” A Lab 1 built on another PC is on the phone. Uninstall Notes on the phone, then click ▶ again.
  • BUILD FAILED: “jlink executable … does not exist” A Gradle process left by VS Code: see If it doesn’t work, below.
  • The phone opened in its own window, not in Running Devices You started it from the Welcome window. Close that window, then start it from the project’s Device Manager.

No file changes in this step: the build only reads the project.

If it doesn’t work

  • BUILD FAILED: “jlink executable …\.vscode\extensions\redhat.java-…\bin\jlink.exe does not exist” Android Studio reused a Gradle process that VS Code left running on its own Java. Close VS Code. In Android Studio’s Terminal, type .\gradlew --stop, press Enter, then build again (▶, or Build & Refresh in the preview).
  • The build asks for compileSdk 37.1 A version update was accepted. In Gradle Scriptslibs.versions.toml, set composeBom = "2026.02.01", then click Sync Now.

The shortcuts of this lab

  • Shift+F10: ▶ Run 'app', build and open the app on the phone.
  • Ctrl+Shift+F5: Build & Refresh, the preview drawn again (Part 1).
  • Alt+Enter: the quick fix, for example a missing import.
  • Ctrl+Space: completion.
The same keys as Lab 1, and one for the preview. On a Mac, Cmd replaces Ctrl.

End of the part

Recap

The Compose libraries are downloaded, and the project runs under Lab 1’s package: one Notes on the phone. That’s all for tonight. In class, you open MainActivity.kt and look for the layout.

  • read a line of Kotlin beside the Java you know;
  • create a Compose project with Empty Activity, under Lab 1’s package;
  • run it: “Hello Android!” replaces Lab 1’s Notes on the phone.
Your app at the end of Part 0: “Hello Android!” at the top left of a white screen.
Your app now