Initial Movies UI

Update versions

Starting with a clean project, we need to update our versions to match those in Course hardware and software.

Note

If you do not have gradle/libs.versions.toml in your project, you didn't choose the Gradle Version Catalog option when creating your project. I recommend deleting the project and starting again, making sure you choose the version catalog option under Build configuration language.

When I created this project using Android Studio Ladybug, I had to update the Compose BOM version in gradle/libs.versions.toml:

show in full file gradle/libs.versions.toml
[versions]
//agp = "8.7.2"
//kotlin = "2.0.0"
agp = "8.7.3"
kotlin = "2.0.21"
coreKtx = "1.15.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
lifecycleRuntimeKtx = "2.8.7"
activityCompose = "1.9.3"
//composeBom = "2024.04.01"
composeBom = "2024.12.01"

[libraries]
// ...
[plugins]
// ...

and the Android SDK version (compileSdk and targetSdk) in app/build.versions.kts:

show in full file app/build.gradle.kts
// ...
android {
    namespace = "com.androidbyexample.compose.movies"
//  compileSdk = 34
    compileSdk = 35

    defaultConfig {
        applicationId = "com.androidbyexample.compose.movies"
        minSdk = 24
//      targetSdk = 34
        targetSdk = 35
        versionCode = 1
        versionName = "1.0"
        // ...
    }
    // ...
}
// ...

Note

See Android SDK settings for details on compileSdk and targetSdk.

After updating the files, you'll need to re-synchronize them with Android Studio. Android Studio reads the build scripts to determine which modules and which dependencies are used so it can provide code-assist and lint checks in the IDE.

Note

Make sure you update to the versions specified in Course hardware and software! The versions you see here are the last ones I've edited, and may be a few terms old.

When you change a build script, Android Studio will normally display a banner at the top of the file indicating that it needs to be re-synchronized, and you can click "Sync Now" to do so. Otherwise you can click the elephant icon on the toolbar to perform this synchronization.


All code changes

CHANGED: app/build.gradle.kts
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.kotlin.compose)
}

android { namespace = "com.androidbyexample.compose.movies" // compileSdk = 34 compileSdk = 35 defaultConfig { applicationId = "com.androidbyexample.compose.movies" minSdk = 24 // targetSdk = 34 targetSdk = 35
versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { isMinifyEnabled = false proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) } } compileOptions { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } kotlinOptions { jvmTarget = "11" } buildFeatures { compose = true } } dependencies { implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx) implementation(libs.androidx.activity.compose) implementation(platform(libs.androidx.compose.bom)) implementation(libs.androidx.ui) implementation(libs.androidx.ui.graphics) implementation(libs.androidx.ui.tooling.preview) implementation(libs.androidx.material3) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.ui.test.junit4) debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.test.manifest) }
CHANGED: gradle/libs.versions.toml
[versions] //agp = "8.7.2" //kotlin = "2.0.0" agp = "8.7.3" kotlin = "2.0.21" coreKtx = "1.15.0" junit = "4.13.2" junitVersion = "1.2.1" espressoCore = "3.6.1" lifecycleRuntimeKtx = "2.8.7" activityCompose = "1.9.3" //composeBom = "2024.04.01" composeBom = "2024.12.01"
[libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } androidx-ui = { group = "androidx.compose.ui", name = "ui" } androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } androidx-material3 = { group = "androidx.compose.material3", name = "material3" } [plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }