MacBook pro mid 2014 with High Sierra and APFS - Overallocation Detected on main device
Solution 1:
I would have commented on Peku2455's answer, but I don't have 50 rep. So here is the solution, based on Peku's answer (which is missing the -o switch to fix overallocation)
In Terminal in Recovery Mode (press Command+R while booting, select Utilities -> Terminal):
diskutil unmountDisk /dev/disk0
fsck_apfs -oy /dev/disk0
Solution 2:
I booted in Recovery mode, open Terminal and run diskutil unmountDisk /dev/disk0
and after that fsck_apfs -y /dev/disk0
After this all was fine
Maybe for you, the drive name is different, you can find it by running diskutil list