πŸ› Debugging Actifit + Health Connect: How I Found the Root Cause / Como Encontrei a Causa Raiz

in #actifit β€’ last month


English


While using Actifit on my Realme C75, I noticed the app wasn't loading any data from Health Connect. No steps, no activity β€” just empty screens.

I decided to dig deeper using ADB logcat and found this exception being thrown every time the app tried to sync:

java.lang.IllegalArgumentException: startTime must be before endTime.
    at androidx.health.connect.client.records.StepsRecord.<init>

After investigation, I discovered the culprit: the Realme C75's native step counter writes records to Health Connect where startTime == endTime (zero duration). Health Connect accepts these records on write, but the Kotlin SDK rejects them on read β€” causing the entire coroutine to cancel and no data to load.

Workaround: Revoke the Realme system app's write permission for Steps in Health Connect and delete its existing records. After that, Actifit loads data normally.

Stay tuned for a detailed post with the full investigation!

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

PortuguΓͺs

Enquanto usava o Actifit no meu Realme C75, percebi que o app nΓ£o carregava nenhum dado do Health Connect. Sem passos, sem atividade β€” telas vazias.

Resolvi investigar usando ADB logcat e encontrei esta exceΓ§Γ£o sendo lanΓ§ada toda vez que o app tentava sincronizar:

java.lang.IllegalArgumentException: startTime must be before endTime.
    at androidx.health.connect.client.records.StepsRecord.<init>

ApΓ³s investigaΓ§Γ£o, descobri o culpado: o contador de passos nativo do Realme C75 grava registros no Health Connect onde startTime == endTime (duraΓ§Γ£o zero). O Health Connect aceita esses registros na escrita, mas o SDK Kotlin os rejeita na leitura β€” cancelando toda a coroutine e impedindo qualquer dado de carregar.

SoluΓ§Γ£o temporΓ‘ria: Revogar a permissΓ£o de escrita de Passos do app do Realme no Health Connect e deletar os registros existentes. ApΓ³s isso, o Actifit carrega os dados normalmente.

Em breve um post detalhado com toda a investigaΓ§Γ£o!