public Bitmap getBitmapFromDrawable(int drawableId) {
        Drawable drawable = AppCompatResources.getDrawable(context, drawableId);

        if (drawable instanceof BitmapDrawable) {
            return ((BitmapDrawable) drawable).getBitmap();

        } else if (drawable instanceof VectorDrawableCompat || drawable instanceof VectorDrawable) {
            Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap);
            drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
            drawable.draw(canvas);
            return bitmap;
        }

        Log.e(TAG, "Unsupported drawable type: " + drawable.getClass().getName());
        return null;
    }
Get a bitmap from a drawable resource, which can be a bitmap or vector drawable.
@param drawableId
@return The bitmap or null if the drawable type is unsupported.
src/android/util/AssetUtil.java