question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash when loading image into AppCompatImageView

See original GitHub issue

I attempted to migrate from Glide to Coil in my app. After switching to Coil, the app crashed in runtime as soon as an image was downloaded when it was being set to a androidx.appcompat.widget.AppCompatImageView descendant. May be worth to note, that I’m using this ui library: https://github.com/stfalcon-studio/ChatKit Could you help me understand what the issue is and if there are any possible workarounds?

Here’s the stacktrace: java.lang.IllegalArgumentException: Software rendering doesn't support hardware bitmaps at android.graphics.BaseCanvas.onHwBitmapInSwMode(BaseCanvas.java:550) at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:557) at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:69) at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:127) at android.graphics.Canvas.drawBitmap(Canvas.java:1504) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:545) at android.widget.ImageView.onDraw(ImageView.java:1360) at com.stfalcon.chatkit.utils.ShapeImageView.onDraw(ShapeImageView.java:70) at android.view.View.draw(View.java:20207) at android.view.View.buildDrawingCacheImpl(View.java:19478) at android.view.View.buildDrawingCache(View.java:19338) at android.view.View.draw(View.java:19927) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19073) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5011) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw(View.java:20210) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4410) at android.view.View.updateDisplayListIfDirty(View.java:19082) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023) at android.view.View.draw(View.java:20210) at android.view.View.updateDisplayListIfDirty(View.java:19082) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw(View.java:20210) at android.view.View.updateDisplayListIfDirty(View.java:19082) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19073) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19073) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19073) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.updateDisplayListIfDirty(View.java:19073) at android.view.View.draw(View.java:19935) at android.view.ViewGroup.drawChild(ViewGroup.java:4333) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4112) at android.view.View.draw(View.java:20210) at com.android.internal.policy.DecorView.draw(DecorView.java:780) at android.view.View.updateDisplayListIfDirty(View.java:19082) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:801) at android.view.ViewRootImpl.draw(ViewRootImpl.java:3311) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3115) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2484) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949) at android.view.Choreographer.doCallbacks(Choreographer.java:761) at android.view.Choreographer.doFrame(Choreographer.java:696) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
colinrtwhitecommented, Aug 15, 2019

Do you have View.LAYER_TYPE_SOFTWARE set on your ImageView or do you know if the library enables software rendering behind the scenes? Either way you should be able to fix this by using:

imageView.load(url) {
    allowHardware(false)
}

This prevents using hardware Bitmaps for that request.

0reactions
janbararicommented, Nov 5, 2021

I fixed this issue by adding allowHardware(false) in my coil configuration

Read more comments on GitHub >

github_iconTop Results From Across the Web

App crashes when adding an ImageView? - Stack Overflow
Image resolution/dimension is the problem. Just check and change the resolution/dimension of the image file to a suitable size for mobile ...
Read more >
ImageView.ScaleType - Android Developers
Center the image in the view, but perform no scaling. ... Scale the image uniformly (maintain the image's aspect ratio) so that both...
Read more >
AS 2.3 Canary 3 - AppCompat views crash the layout preview ...
I am unable to preview (or use designview) any layouts that use views from v7 or the design libs. ... <init>(AppCompatImageView.java:63)
Read more >
Android: CircleImageView Simplified | by Ramiz Raja - Medium
These libraries ultimately resulted in a lot of bugs and crashes. ... //fill in the whole image view, crop if needed while keeping...
Read more >
Repeatable app crash / exception at startup on old 5.1.1 ...
An unhandled exception happens on an old android tablet upon ... setImageResource(AppCompatImageView.java:2) E/AndroidRuntime( 6081): at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found