Fortunatly the solution is simple, we have to deactivate the device administrator right of the app. These are the steps we need: go to the settings, and navigate to security
Then select Device administrators
Tap on Turn off screen to deactivate the device administrator right
Finally tap on deactivate
At this point the uninstall button is enabled, so we can remove the app
In order to make this operation faster I put in the main activity of my app an uninstall option, which automatically deactivates the administrator device and shows the uninstalling activity.