Chip chip = new Chip(context);
chip.setBackgroundcolor(getResources().getColor(R.color.blue));
The above line gives the error:
java.lang.UnsupportedOperationException: Do not set the background resource; Chip manages its own background drawable.
You can set background color of material chip by following line (Kotlin)
chip.chipBackgroundColor = getColorStateList(/*your preferred color*/)