Errata for Jetpack Compose by Tutorials, 1st Edition

Creating this topic to catch any typos and bugs in the First Edition of Jetpack Compose by Tutorials.

1 Like

good tutorials.
compose in download files may update to beta-01 ?
and some componment in tutorials is not support any more, scrollColumn?

1 Like

In chapter 3.3, while explaining the Box layout in the book the function MyBox has two parameters (modifier and contentModifier) but in the code there’s only one (modifier).

In chapter 2, the MyRadioGroup() the RadioButton uses parameter color when it should be colors.

Also in chapter 2, the FloatingActionButton no longer has an icon parameter. It looks like they changed it to content.

in the chapter two, val radioButtons = listOf(0, 1, 2) shows an unresolved reference for listOf() did they change sth about this or how can i fix?

Is there an update on this issue? I’m also having the same problem.


:slightly_smiling_face: In chapter 9, in part “Implementing the app drawer footer” there is a bug, because Icon doesn’t have clickable property, so need to use IconButton or another way.

1 Like

:kissing_heart: Thanks! You’re a cute boy!

:point_right: For the building the app in chapter 10, I was fixed as follows (Artic Fox | 2020.3.1 patch 3):

  • The AppDrawer.kt/ AppDrawerFooter():
    Replacing the last Image of that function by:
    IconButton(
    onClick = { changeTheme() },
    modifier = modifier
    .constrainAs(darkModeButton) {
    end.linkTo(parent.end)
    centerVerticallyTo(settingsImage)
    }) {
    Icon(
    imageVector = ImageVector.vectorResource(id = R.drawable.ic_moon),
    contentDescription = stringResource(id = R.string.change_theme),
    tint = colors.primaryVariant
    )

  • The build.gradle (project):
    //Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
    ext.kotlin_version = “1.6.0”
    ext.compose_version = ‘1.1.0-rc01’
    ext.compose_ui_version = ‘1.4.0’

        repositories {
          google()
          jcenter()
        }
        dependencies {
          classpath 'com.android.tools.build:gradle:7.0.3'
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
        }
      }
    

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

  • The build.gradle (app):
    plugins {
    id ‘com.android.application’
    id ‘kotlin-android’
    id ‘kotlin-kapt’
    }

android {
compileSdkVersion 31
buildToolsVersion “30.0.2”

defaultConfig {
applicationId “com.raywenderlich.android.jetnotes”

minSdkVersion 26
targetSdkVersion 31

versionCode 1
versionName "1.0"

vectorDrawables.useSupportLibrary = true

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android-optimize.txt’), ‘proguard-rules.pro’
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = ‘1.8’
allWarningsAsErrors = false
}

buildFeatures {
compose true
}

composeOptions {
kotlinCompilerVersion kotlin_version
kotlinCompilerExtensionVersion compose_version
}
}

dependencies {

// Kotlin
implementation “org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version”

// Default
implementation “androidx.core:core-ktx:1.7.0”
implementation “androidx.appcompat:appcompat:1.4.0”
implementation “androidx.constraintlayout:constraintlayout:2.1.2”
implementation “androidx.activity:activity-ktx:1.4.0”
implementation “androidx.activity:activity-compose:$compose_ui_version”

// Material
implementation “com.google.android.material:material:1.4.0”

// Compose
implementation “androidx.compose.runtime:runtime:$compose_version”
implementation “androidx.compose.runtime:runtime-livedata:$compose_version”
implementation “androidx.compose.ui:ui:$compose_version”
implementation “androidx.compose.foundation:foundation-layout:$compose_version”
implementation “androidx.compose.material:material:$compose_version”
implementation “androidx.compose.material:material-icons-extended:$compose_version”
implementation “androidx.compose.foundation:foundation:$compose_version”
implementation “androidx.compose.animation:animation:$compose_version”
implementation “androidx.compose.ui:ui-tooling:$compose_version”
implementation “androidx.constraintlayout:constraintlayout-compose:1.0.0-rc02”

// Room
implementation “androidx.room:room-runtime:2.3.0”
kapt “androidx.room:room-compiler:2.3.0”

// Coroutines
implementation “org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0”
implementation “androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0”
}
And the AndroidManifest.xml:

1 Like

:laughing: I have been completed this book’s guidelines. Thanks to Reywenderlich’s team! :kissing_heart:

Hi !
Sample codes in this books have very bad practice for accessibility (sometimes contentDescription brings no valuable information, some other times contentDescription mention redundant information like “buttons” and sometimes also image/icon should be ignored. It could be nice to improve those issue in your next version of this book. Also could be nice to add a chapter on accessibility. Semantics are easy to use and it’s a shame to not mentioned it !

Grammatical glitch, page 305
Jetpack Compose offers a list of events that can trigger at specific points in the the

Two the’s in that statement.

Took me a while to figure out that to build an OutlinedTextField, the proposed parameters are non existing anymore, specifically activeColor. Instead of this:

OutlinedTextField(
    label = { Text(text = stringResource(id = R.string.email)) },
    activeColor = colorResource(id = R.color.colorPrimary),
    keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Email),
    value = textValue.value,
    onValueChange = {
      textValue.value = it
    },
  )

it is this

OutlinedTextField(
            value = textValue.value,
            onValueChange = {
                textValue.value = it
            },
            label = { Text(text = stringResource(id = R.string.email)) },
            colors = TextFieldDefaults.outlinedTextFieldColors(
                focusedBorderColor = colorResource(id = R.color.colorPrimary)
            ),
            keyboardOptions = KeyboardOptions.Default.copy(keyboardType = KeyboardType.Email),
        )

notice colors instead of activeColor.
Of course it is hard to keep up to date with all the changes but this forces you to search and “waste” time outside when the idea is to basically follow through the course using more concise material.