I started getting this problem in 2017 and this solution worked for me. Clear data and cache on camera app and force stop. Switch of fast boot. Power off, wait a few seconds and then Power on again. Camera started working when the phone was back on. Thanks.