Creating this topic to catch any typos and bugs in the First Edition of Jetpack Compose by Tutorials.
good tutorials.
compose in download files may update to beta-01 ?
and some componment in tutorials is not support any more, scrollColumn?
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.
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.
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:
I have been completed this bookâs guidelines. Thanks to Reywenderlichâs team!
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.
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 beTextField
(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.
Errata for Chapter 3
-
"Start by replacing
MyRow()
" â should beMyRow()
. -
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
vssecondary = rwRed
. -
Section âKey pointsâ, you mention
OnBackPressedDispatcherOwner
andAmbient
which is not mentioned in the chapter before. Did you meanBackHandler
?
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 ???