I have an affordable priced but good phone: a Xiaomi Redmi 4X. It has a customized Android by Xiaomi – the MIUI, which I love and hate in the same time. I love the simplicity of the launcher and the dense option of the settings and I hate that I need to change a lot of settings to able to receive push notifications for specific apps. Why that has to be so complicated, maybe because of security, I’m not sure…
Anyway, similar complicated setup needed to able to run and debug Android apps directly from Android Studio via USB. It was difficult to find out, but finally I got success, these were the steps how to achieve:
- First have to enable the Developer options in the Android’s settings, like any other Android device.
- Settings -> Additional Settings -> Developer options -> Turn off Miui Optimizations -> Restart
- Security -> Permissions -> Gear Icon at top right corner -> Turn On “Install via USB”
- Settings -> Additional Settings -> Developer options -> Turn On/Off “USB Debugging” -> Turn On “Install via USB”
Well, this is the tricky part. For some reason, the device allow to enable this only if has an added MI Account and have internet connection from China. Otherwise, it says ‘The device is temporarily restricted’. I assume Xiaomi wants to know who enable this setting, but they use a server which is behind the Great Firewall of China? Anyway, since I’m in Europe, I can workaround the second requirement via VPN very easily:
- Install a free VPN app, e.g. PlexVPN from the Google Play
- Signup for a free one day trial
- Change the VPN server to China – Shanghai and connect the VPN
- Turn On “Install via USB” should work now. You can even uninstall the PlexVPN after the enabling.
- The result can be checked via the Select Deployment Target form: Run -> Profile ‘your app’. The phone should be on the list.
Most the steps I learned from the MIUI forum: http://en.miui.com/thread-544718-1-1.html
Check also the phone itself – it may ask permission to use USB debugging in a popup!
If still not work, check and fix the ADB driver like:
Install the Minimal ADB and Fastboot package from XDA developers (https://forum.xda-developers.com/sho….php?t=2317790 –> https://www.androidfilehost.com/?fid=745425885120698566)
Note, the “Stock” Google USB Driver didn’t worked for me for the Redmi4X. Which can be downloaded in the Android SDK manager and set up like this:
- SDK Manager -> SDK Tools -> Install “Google USB Driver”
- Go to Windows Device Manager, find “ADB Interface” -> update driver -> select manually -> select from list -> all devices -> select folder “C:\Users\Username\AppData\Local\Android\sdk\extra s\google\usb_driver” -> select “Android ADB Interface”
- Windows will warn you that this driver might not work, install it anyway
- Device manager will show “Android ADB Interface” in the category “SAMSUNG Android Phone”
For quicker run, you can disable the selector dialog by Run -> Edit Configuration -> General -> Deployment Target Options -> Target: change to USB Device
Good luck! 😉