Crash when starting the app on branch `start_kotlin` using xxhdpi device

Open
#257 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
android, kotlin
Domain
mobile

Research direction

Start on the start_kotlin branch by locating the android_cupcake.png drawable and its references. Reproduce the launch on an xxhdpi Android device or emulator, then verify that the app starts without the oversized-bitmap crash while retaining the image.

Written by the indexing model from the issue text.

Description

I just started the app as proposed in codelab and this happened:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.background, PID: 24751
    java.lang.RuntimeException: Canvas: trying to draw too large(118054944bytes) bitmap.
        at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)
        at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:97)
        at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:529)
...

Device:

Moto G 5
API Level 27

As described in this answer:

When an image that is only in drawable/folder is used on xxhdpi device, the potentially already big image is upscaled by a factor of 3, which can then in some cases cause the image's memory footprint to explode.

In the case of this project the error is happening due to the drawable android_cupcake.png

Dominant language
Kotlin
Stars
557
Forks
242
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from android/codelab-android-workmanager

All issues in android/codelab-android-workmanager

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.