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.

2 Likes

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

2 Likes

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.

appdrawer.kt
: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

: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:
Chapter10_3

1 Like

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

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.

1 Like

Errata for Chapter 2

  • Please reformat the code to use two space indentation for all the source code in the chapter. Actually, I’ve seen in several chapters of the book that you’re using four space indentation, also two and three space indentation. I believe you should stick to one code style.

  • TexField should be TextField (missing t).

  • “Note that it’s of type TextFieldValue and not String.” → Actually it’s a String.

  • “The callback provides a new TextFieldValue so you can update the displayed text.” → It should be String instead of TextFieldValue.

  • “Open ProgressIndicatorScreen.kt” → should be ProgressIndicatorsScreen.kt (with s) or you should rename the file.

  • The README.md file has a 2020 license, but it should be 2021 as the rest of the code.

3 Likes

Errata for Chapter 3

  • "Start by replacing MyRow() " → should be MyRow().

  • The README.md file has a 2020 license, but it should be 2021 as the rest of the code. I think this may apply to all the chapters.

Errata for Chapter 4

  • Book Categories image → The violet group should be CATEGORY3.

  • ListScreen.kt of the starter project should use two space indentantion.

  • TextScreen.kt of the starter and final projects should use two space indentantion.

  • Review space indentantion for the book code, e.g. LazyListScope uses four space indentation.

Errata for Chapter 5

  • Projects don’t have README.md, but previous projects had one. You’d like to unify criteria.

  • RepositoryImpl in starter/final projects should use isEmpty instead of isNullOrEmpty.

  • In RepositoryImpl why are you using GlobalScope.launch? You’re not using coroutines. Did you forget to use suspend keyword on dao functions?

Errata for Chapter 7

  • onCreateNoteClick() should be onCreateNewNoteClick()

Errata for Chapter 8

  • Section “Adding support for the Back button”, where it states “Currently, when you open the Save Note screen and press the Back button, the app closes.”. First, I thought you were talking about the button of the top bar, where it does work as expected, pressing it goes to the Notes screen. Then I realized that you were talking about the device’s back button. Maybe you’d like to clarify that better :]
    Also, after adding the BackHandler, pressing the device’s back button does close the bottom drawer, but pressing the top bar back button does not. Maybe you’d like to unify that behavior.

  • Section “Theming in Compose”, Theme.kt code doesn’t match article starter code.
    secondary = rwGreen vs secondary = rwRed.

  • Section “Key points”, you mention OnBackPressedDispatcherOwner and Ambient which is not mentioned in the chapter before. Did you mean BackHandler?

Chapter 4 - ScrollableColumn / Row - the book describes the usage of these composable functions but as per Google Issue Tracker

ScrollableColumn/Row were deprecated. Using ScrollableColumn is less efficient comparing to LazyColumn when you have a large scrolling content because with LazyColumn we can only compose/measure/draw visible elements. To prevent users from going inefficient way we decided to deprecate ScrollableColumn and ScrollableRow and promote usages of LazyColumn and LazyRow instead. Users can still decide they don’t need the lazy behaviour and use the modifiers directly like this: Column(Modifier.verticalScroll(rememberScrollState()))

What is the correct Code for Point 3 and 4 ???