I was using the in-built emulator and kept encountering this problem.
To fix it:
- Go to: Run > Edit Configurations
- Click your device in the dropdown near "Preferred Android Virtual Device" and press Shift + Enter
- Close the config screen, and focus the new window with the AVDs.
- On the emulator you use choose the menu option on the right, and choose "stop" and "wipe data".
- For good measure: Build > Clean Project
Some of this might be unnecessary but I can't replicate the problem deliberately in order to trial a minimum amount of steps