Unexpected Output: register_activation_hook with namespace

When we are outside the Sample namespace, we should call the function by \Sample\sp_activate(), so please try the following:

<?php
/**
 * Plugin Name: Sample Plugin
 * Version:     0.0.2
 */

namespace Sample;

\register_activation_hook( __FILE__, '\Sample\sp_activate' );

function sp_activate() {

}

If something is printed out during the plugin activation it will result in unexpected output message. If you use for example echo 'Hello'; in your activation function, it will generate such a message of 5 characters.

You should consider using WP_DEBUG_LOG and log the errors into a file, to see what kind of errors you’re getting there.

I hope this helps.