Development in the Ionic framework is mostly handled through CMD Command prompt. We can open code, create APK packages, install plugins etc from CMD itself. But sometimes to test some of the Ionic Native plugins need a real device, for that we may create APK using $ ionic cordova build android and then we can transfer the generated an APK in the phone.
This will surely slow down the development process if the testing and debug is repeated many times. So it’s better to install debug version of our APK file directly in a mobile device connected to our Computer. After connecting device using a USB cable, we can directly install and debug an application in the phone like as we do use Android Studio environment. We only need to run the following command in project root in CMD for device debugging
$ ionic cordova run android --device
but this command will give an error if CMD does not find any attached device. This happens when USB Debugging is not enabled in a device. USB Debugging enables a mobile device to be used for debugging and installing of APK files through a USB wire. So next we will get to know
How to Enable USB Debugging in Android Device?
I have Mi’s Xiomi Note 3 mobile currently having latest MIUI 10 And it’s Cool 😛
Step 1) Goto settings then Tap on “About phone”
Step 2) Now Tap on “MIUI version” row for about 10 times then, a toast will show up “You are now a developer”
Step 3) About procedure will add “Developer options” row under “Additional settings”
Step 4) Under “Developer options” Turn ON “USB debugging” and “Install via USB” options. Also Turn OFF “Turn on MIUI optimization” as sometimes it does not allow to install apps on a mobile device.
After following the above options you can easily debug your applications directly in the real device using a USB cable. This will make Ionic Development very easy and fast. Above tutorial is for MiUI but most android phones has the same to options to turn on developer options for USB debugging.