Failure [INSTALL_CANCELED_BY_USER] on Xiaomi device

Just to help anyone who have the same problem: it was entirely related to the "Install via USB" option in the Developer mode, that MIUI would not let me activate. After numerous attempts and reboots of the device, it finally activated and the deploy worked at the same time.


In MIUI the UI does some of the optimization for some reason, but this comes out to be an error while running the app on the phone through Android Studio. We need to stop the optimization:

Go to -> Settings -> Switch on the developer option (hope you know) -> Go to developer settings -> Turn off MIUI optimization

I hope this works for you. ;)