Skip to content

AndroLog returns 0% code coverage when using PowerShell on Windows due to encoding mismatch #9

Description

@Florence-Njeri

Description:

Hi professor, I encountered a major blocker while generating code coverage for my instrumented application. The issue was that I was capturing and saving logcat logs using PowerShell on Windows, which by default saves files in UTF-16 encoding. However, AndroLog expects UTF-8 encoded log files for parsing. This caused me to consistently get 0% code coverage despite having valid METHOD entries in my logs.

Root Cause:

PowerShell's > redirect operator saves files in UTF-16 LE (with BOM) by default, which breaks AndroLog's log parser. This is a Windows PowerShell-specific issue that doesn't affect Mac/Linux users where the default encoding is UTF-8.

Solution:

After modifying my PowerShell command to explicitly save the output as UTF-8, the code coverage generation worked correctly.

Working command for Windows PowerShell users:

adb logcat -v threadtime MY_SUPER_LOG:D *:S | Out-File -FilePath logs.txt -Encoding UTF8

Suggestion:

It would be helpful to add a note in the README about this Windows PowerShell-specific encoding issue to help future users avoid this problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions