Errata for Android Apprentice 4th Edition

Creating this topic to catch any typos and bugs in the 4th Edition of Android Apprentice.


I wasn’t able to compile any of the sample code in 8. SharedPreferences & ViewModels, Section “Adding a Dialog” without doing additional steps such as importing various missing references:

import android.text.InputType
import android.widget.EditText
import com.raywenderlich.listmaker.databinding.MainActivityBinding

Not sure if that was intended or not but thought I’d mention it.

Hi cpg6b,

Thank you for letting us know about this. I downloaded the final project for chapter 8 and can compile the app with no issue.

I was wondering if you could be more specific about the issue. Was it following along with the chapter, or something else?

Thanks for your response @daemonic_daz. I didn’t have a chance yet to try the downloadable sample — instead I was just following along in the chapter with adding the sample code as instructed line by line from the very beginning. Sorry for not being more clear about that.

If you start the Chapter from the beginning as a fresh project and then add or replace the lines of code as instructed, I think you’ll probably find that there might be an instruction missing along the way somewhere about adding the import statements as needed for those various objects.

If you need any more information, please let me.


Sorry forgot to remind you that it’s specifically the code in the “Adding a Dialog Part”

Hi @cpg6b,

Thank you for the information. I think this is something we’ll keep in mind. We do cover how to import classes in Chapter 3. Whether that’s enough is another discussion.

Chapter 7
!Here, you’re telling gradle to add the viewBinding feature to your app. Next, you need to start using data binding"

start using view binding instead of data binding?

In chapter 4: Debugging, there is one more bug which should be fixed.

Steps to reproduce:

  1. Run the final project
  2. Rotate device without hitting tap button.

Expected: The timer should not run
Actual: Timer started running even if ‘Tap me!’ button wasn’t pressed once.


override fun onSaveInstanceState(outState: Bundle) {
        if (gameStarted) {
            outState.putInt(SCORE_KEY, score)
            outState.putInt(TIME_LEFT_KEY, timeLeft)

            Log.d(TAG, "onSaveInstanceState: Saving score: $score & Time left: $timeLeft")

Explaination: score and time left should only be saved in case game has started.

Hi, I am stuck at page 500 of the book. Cant figure out how to finish “SearchViewModel” class properly. Would it be possible for you to provide me the whole complete file so I can see where im going wrong. So far I have been able to follow along but cant get past this. I only have the paper version of the book. I think I also found a couple of typos in the book if you can call them that:

page 484:

GlobalScope.launch {
val results = itunesRepo.searchByTerm(“Android Developer”)
Log.i(TAG, “Results = ${results.body()}”) <-----missing the closing bracket of {results.body()

page 491:

reads as follows


but I got it work the other way around:


could be these are my mistakes since I am a novice and dont understand much but I thought I’d let you know in case these are typos.

Can I download the source code for this project from somewhere?


Yes indeed. All the source code is in the GitHub repo.

For 4th edition, all the code is here:



When we move the logic for adding a new task to the MainViewModel in the chapter 11, the following source code is used in the book:

fun addTask(task: String) {

I have noticed, that data is not saved to the Shared preferences when app is running on the tablet, because onActivityResult is not called.
However, in the source code for the final project from the book the code for this function differs:

  fun addTask(task: String) {

Here the data is saved to the Shared preferences using updateList(list) method and everything works as expected.

Additionally, it seems the updateList(list:) method in the book contains an issue:

  fun updateList(list: TaskList) {
      .putStringSet(, list.tasks.toHashSet())

lists.add(list) call is not needed and it is removed in the final project source code too.

I think the source code in the book should be updated, because it is incorrect.

Thank you for pointing this out. I’ve opened an issue for the book so that this is corrected for the next edition!

But this has not been fixed, the entire code of the book is full of errors. It is not possible to execute the code step by step following the instructions in the book. If we compare the code on github and the code of the book, we will find big differences. I feel cheated, return the money for the subscription