Your bitmap should be a modified bitmap.
when your bitmap is like this
Bitmap bitmap = .......
then convert it to a mutable bitmap using below
Bitmap mutableBitmap = bitmap.copy (bitmap .Config.ARGB_8888, true);
then mutableBitmap.eraseColor (somecolor);
source share