This error probably occurs when you try to add a custom block to a region.

When you get this error, you probably made a typo in your namespace. Namespace should be:

namespace Drupal\my_module\Plugin\Block;

If you moved your code around too much, this can help:

In local.settings.php add:

$settings['class_loader_auto_detect'] = FALSE;