I am trying to create a simple widget that has only a toggle button but I keep getting an error on my AVD emulator saying "Problem loading Widget".
It seems to be because I add a switch or toggle button to the widget layout.
To test it I created a new empty activity application, added a widget and then added a switch button.
The application builds and installs correctly but when I add the widget to my homepage on my emulator (Pixel 2 API 30) I get the following error.
I have checked logcat but can't see any errors in there. Does anyone know what I am doing wrong?

