Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Software rendering doesn't support hardware bitmap in Oreo

Tags:

android

LinearLayout llQRCodeShare;
try {
    llQRCodeShare.setDrawingCacheEnabled(true);
    llQRCodeShare.buildDrawingCache(true);
    Bitmap b = llQRCodeShare.getDrawingCache();
    Bitmap bitmap = Bitmap.createBitmap(b);
    llQRCodeShare.setDrawingCacheEnabled(false);
} catch (IllegalStateException e) {
    LogUtil.e(TAG, e.getMessage());    //Software rendering doesn't support hardware bitmap
}

when execute the code"llQRCodeShare.getDrawingCache()",throws the exception,

Software rendering doesn't support hardware bitmap

on the android8.0.
How to solve it?

like image 955
Wow Chong Avatar asked Dec 29 '17 11:12

Wow Chong


2 Answers

disable hardware acceleration either for the whole Activity:

android:hardwareAccelerated="false"

or for that one particular View:

llQRCodeShare.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
like image 165
Martin Zeitler Avatar answered Nov 15 '22 08:11

Martin Zeitler


just make the android:hardwareAccelerated="true" in the AndroidManifest.xml under Application tag

like image 3
Guru Prasad mohapatra Avatar answered Nov 15 '22 09:11

Guru Prasad mohapatra