The "cannot be connected to the camera" error is a common issue with Android devices and could stem from software glitches, app conflicts, or hardware problems.
Close all recent apps or restart your phone in Safe Mode to test: To enter Safe Mode: Press and hold the power button, then long-press "Power Off" until Safe Mode appears. Restart normally afterward.
If the camera works in Safe Mode, a third-party app is likely the culprit—uninstall recent apps one by one to identify it.
Also please let me know if the error happen with both front and back cameras.