Hi, I encountered problem while loading image in devices OS Oreo. It throws an error: java.lang.IllegalStateException: Software rendering doesn't support hardware bitmaps
Here is whole error report:
java.lang.IllegalStateException: Software rendering doesn't support hardware bitmaps
at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:532)
at android.graphics.BaseCanvas.throwIfHasHwBitmapInSwMode(BaseCanvas.java:548)
at android.graphics.BaseCanvas.throwIfHasHwBitmapInSwMode(BaseCanvas.java:540)
at android.graphics.BaseCanvas.drawCircle(BaseCanvas.java:227)
at android.graphics.Canvas.drawCircle(Canvas.java:1526)
at com.mikhaellopez.circularimageview.CircularImageView.onDraw(CircularImageView.kt:255)
at android.view.View.draw(View.java:19218)
at android.view.View.buildDrawingCacheImpl(View.java:18466)
at android.view.View.buildDrawingCache(View.java:18326)
at android.view.View.draw(View.java:18938)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.draw(View.java:19221)
at android.view.View.updateDisplayListIfDirty(View.java:18168)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5204)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at android.view.View.draw(View.java:19221)
at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4603)
at android.view.View.updateDisplayListIfDirty(View.java:18168)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.draw(View.java:19221)
at android.view.View.updateDisplayListIfDirty(View.java:18168)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:268)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:256)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024)
at android.view.View.updateDisplayListIfDirty(View.java:18159)
at android.view.View.draw(View.java:18946)
at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
I had similar issue while loading bitmap in ImageView and solved it like code bellow or by setting <application android:hardwareAccelerated="false" ...>, which I don't wanna!
fun View.toBitmap(window: Window, bitmapCallback: (Bitmap)-> Unit) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Above Android O, use PixelCopy
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val location = IntArray(2)
getLocationInWindow(location)
PixelCopy.request(window,
Rect(location[0], location[1], location[0] + width, location[1] + height),
bitmap,
{
if (it == PixelCopy.SUCCESS) {
bitmapCallback.invoke(bitmap)
}
},
Handler(Looper.getMainLooper()) )
} else {
val tBitmap = Bitmap.createBitmap(
width, height, Bitmap.Config.RGB_565
)
val canvas = Canvas(tBitmap)
draw(canvas)
canvas.setBitmap(null)
bitmapCallback.invoke(tBitmap)
}
}
Hi, I encountered problem while loading image in devices OS Oreo. It throws an error: java.lang.IllegalStateException: Software rendering doesn't support hardware bitmaps
Here is whole error report:
java.lang.IllegalStateException: Software rendering doesn't support hardware bitmaps at android.graphics.BaseCanvas.throwIfHwBitmapInSwMode(BaseCanvas.java:532) at android.graphics.BaseCanvas.throwIfHasHwBitmapInSwMode(BaseCanvas.java:548) at android.graphics.BaseCanvas.throwIfHasHwBitmapInSwMode(BaseCanvas.java:540) at android.graphics.BaseCanvas.drawCircle(BaseCanvas.java:227) at android.graphics.Canvas.drawCircle(Canvas.java:1526) at com.mikhaellopez.circularimageview.CircularImageView.onDraw(CircularImageView.kt:255) at android.view.View.draw(View.java:19218) at android.view.View.buildDrawingCacheImpl(View.java:18466) at android.view.View.buildDrawingCache(View.java:18326) at android.view.View.draw(View.java:18938) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994) at android.view.View.draw(View.java:19221) at android.view.View.updateDisplayListIfDirty(View.java:18168) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5204) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at android.view.View.draw(View.java:19221) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4603) at android.view.View.updateDisplayListIfDirty(View.java:18168) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994) at android.view.View.draw(View.java:19221) at android.view.View.updateDisplayListIfDirty(View.java:18168) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:268) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:256) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1994) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4024) at android.view.View.updateDisplayListIfDirty(View.java:18159) at android.view.View.draw(View.java:18946) at android.view.ViewGroup.drawChild(ViewGroup.java:4238)
I had similar issue while loading bitmap in ImageView and solved it like code bellow or by setting <application android:hardwareAccelerated="false" ...>, which I don't wanna!