Boot Camp Assistant removal successful, still can't reinstall [duplicate]

As it can be seen from the screenshot below my APPLE SSD is of size 500GBs, but my Apple_APFS Container disk1 is of size 450GBs. There was a Container disk 2 of size 50GBs before but I successfully removed it using:

sudo diskutil eraseVolume "Free Space" %noformat% /dev/disk0s4

I tried resizing the main APFS cotnainer with the following command:

diskutil apfs resizeContainer disk0s2 0

but I am getting the following error:

Error: -69519: The target disk is too small for this operation, or a gap is required in your partition map which is missing or too small, which is often caused by an attempt to grow a partition beyond the beginning of another partition or beyond the end of partition map usable space

Following some screenshots displaying the current state of the sysetm:

 diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.3 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         449.3 GB   disk0s2
   3:       Apple_KernelCoreDump                         655.4 MB   disk0s3

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +449.3 GB   disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            362.2 GB   disk1s1
   2:                APFS Volume Preboot                 55.2 MB    disk1s2
   3:                APFS Volume Recovery                517.2 MB   disk1s3
   4:                APFS Volume VM                      1.1 GB     disk1s4

enter image description here

enter image description here

enter image description here


Solution 1:

The output, from the commands below, should show that disk0s3 starts at an offset that is sufficiently close to the end of disk0s2 to produce the error message you posted.

diskutil info disk0s2 | grep -e Offset -e "Disk Size"
diskutil info disk0s3 | grep -e Offset -e "Disk Size"

Or, in other words:

(Offset of disk0s2) + (Size of disk0s2) - (Offset of disk0s3) = (Small enough size to cause message)

You do not need the Apple_KernelCoreDump partition. You can remove this partition be entering the command below.

sudo diskutil eraseVolume "Free Space" none disk0s3

Next, you can reenter the command you posted in your question to reclaim the free space.

diskutil apfs resizeContainer disk0s2 0