google-developer-training / android-kotlin-fundamentals-apps

android-kotlin-fundamentals-apps
Other
1.68k stars 2.12k forks source link

Android Kotlin Fundamentals codelab: Missing Timber.d statement #370

Closed ken-brown closed 4 years ago

ken-brown commented 4 years ago

Describe the problem There is a statement purporting that a Logcat statement should be visible, but there is no place in the code that contains a Timber.d() call that emits that statement. The statement that is supposedly emitted in logcat is: 11:31:44 D/DevByteApplication: Periodic Work request for sync is scheduled But the code does not contain this.

In which lesson and step of the codelab can this issue be found? Lesson number Android Kotlin Fundamentals 09.2: WorkManager + step number 8. Task: Add constraints, step Step 2: Run the app and notice the logs, numbered statement 4.

How to reproduce? What are the exact steps to reproduce the problem? Examine the code in DevBytes-starter at the point where this lesson / task/ statement is and observe that no such Timber.d() statement exists.

Versions

  1. What version of Android Studio are you using? 4.0.1
  2. What API level are you targeting? 28

Additional information I added this statement Timber.d("Periodic Work request for sync is scheduled") before the line: WorkManager.getInstance().enqueueUniquePeriodicWork( RefreshDataWorker.WORK_NAME, ExistingPeriodicWorkPolicy.KEEP, repeatingRequest) in fun setupRecurringWork in DevByteApplication.kt and it behaves as the text indicates

The code is out of sequence, as if you examine the code snippet in Step 3: Add more constraints, numbered statement 4 contains Timber.d("Periodic Work request for sync is scheduled") for the first time. But at the point Step 2 is being described, this statement is not in the code.

codelab: android-kotlin-fundamentals

android-dev-lxl commented 4 years ago

Updated Step 2: Schedule a WorkRequest with WorkManager to include the Timber log. In progress.

android-dev-lxl commented 4 years ago

Thank you for reaching out to us. This should be fixed now.

stevenshapiro commented 3 years ago

The Timber call is missing from the code snippet at the bottom of the page:

class RefreshDataWorker(appContext: Context, params: WorkerParameters) : CoroutineWorker(appContext, params) {

override suspend fun doWork(): Result { val database = getDatabase(applicationContext) val repository = VideosRepository(database) try { repository.refreshVideos() } catch (e: HttpException) { return Result.retry() } return Result.success() } }