Errata for Real-World Android by Tutorials, 1st Edition

Creating this topic to catch any typos and bugs in the 1st Edition of Real-World Android by Tutorials.

In the Building Features – Animals Near You section, the starter project has an older version of Hilt than the finished project. This caused issues with the project unable to resolve the HiltViewModel dependency.

1 Like

In section 2,
10.6 - Handling dependency injection

The DaggerSharingComponent file does not appear in the book.

DaggerSharingComponent.builder ()
.context (requireActivity ())
.moduleDependencies (
EntryPointAccessors.fromApplication (
requireActivity (). applicationContext,
SharingModuleDependencies :: class.java
)
)
.build ()
.inject (this)

2 Likes
  • 13.Custom Views

Understanding the Canvas coordinate system

Figure 13.2 — Android Canvas Coordinates System

In Figure 11.2, you can see that an (x,y) pair represents each…

The correct thing would be: In Figure 13.2, you can see that an (x,y) pair represents each…

For chapter 5, this isn’t really an issue with the book but with the starter code. Once I finished completing the chapter my test wouldn’t pass… I was racking my brain until I realized the fake server couldn’t find the asset file.

I have to make sure my gradle.build file had the sourceSets object setup pointing to the right directory.

Just FYI

1 Like

This is an issue with the book, since chapter 5 makes no mention of the need to set the sourceSets in the gradle.build file. Thankfully you posted here, otherwise I would have also been wracking my brain trying to figure out why my tests were timing out :frowning:

That’s generated by Dagger when annotating with @Component.Builder

@Component(dependencies =[SharingModuleDependencies::class])
interface SharingComponent {
fun inject(fragment: SharingFragment)

**@Component.Builder**
interface Builder {
    fun context(@BindsInstance context: Context): Builder
    fun moduleDependencies(sharingModuleDependencies: SharingModuleDependencies): Builder
    fun build(): SharingComponent
}

}

Chapter 13 - Custom Views - In topic " Binding the animation to the adopt button", the following is not part of the starter code, and is also not mentioned at any point of the chapter:

binding.adoptButton.setOnClickListener {
      binding.adoptButton.startLoading()
      viewModel.handleEvent(AnimalDetailsEvent.AdoptAnimal) //
    }

The Event Adopt Animal is not defined. Also this function is missing in the start project

private fun adoptAnimal() {
    compositeDisposable.add(
        Observable.timer(2L, TimeUnit.SECONDS)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
              _state.value = (_state.value as AnimalDetailsViewState.AnimalDetails?)?.copy(adopted = true)
            }
    )
  }

,thank you so much :handshake:,

(Arctic Fox 2020.3.1 patch 4)
I have the project for chapter 11 configured as follows for Gradle at the project and app levels:

  • Project level:
    11_1

  • app level:
    11_2

:kissing_heart: :kissing_heart: :kissing_heart:

In the last of chapter 16: Conceal library at: GitHub - facebookarchive/conceal: Conceal provides easy Android APIs for performing fast encryption and authentication of data.. That’s True or false?
Thanks!

Been trying to test my network to no avail.I’m at chapter 4.

1 Like

Prior to Style and Themes the book uses coroutines.However in Style and Themes.The writer of that section uses RxJava.
So yeah the function adoptAnimal you posted is an RxJava code which replaces the coroutine code.The write of that section may have preferred to use it as each section is independent. Also if you decide to make a change it is gonna affect your entire code.So here is a simple workaround I did if you writing the full app and want to maintain the coroutine code.

private fun adoptAnimal() {
viewModelScope.launch {
delay(2000)
try {
val adopt = withContext(dispatchersProviders.io()){}
_state.value = (_state.value as AnimalsDetailsViewState.AnimalDetails?)?.copy(adopted = true)
}catch (t:Throwable){
onFailure(t)
}
}
}

hope this helped you out.

This topic was automatically closed after 5 hours. New replies are no longer allowed.