To test or run an android app on real devices such as mobile or phone is faster than AVD. We have different approaches available to run an android app on the real device, those are
If we enable USB Debugging and connect the device to the system, automatically our device will be shown online in the android emulator device list to run our app on the real device.
Instead of enabling USB Debugging, we can directly Build APK for our app in android studio and by installing that APK on our mobile / phone, we can run and test our app.
Now we will see step by step process to enable USB Debugging on Device and Building an APK for an App using the android studio to run and test the app on a real device with examples.
Now open the Settings section in the device which you want to run the android app like as shown below.
In case Developer options not enabled in your phone, search for “About Phone or About Device” option and click on it like as shown below.
After that search for the Build number option and tap on it 7 times to enable Developer options like as shown below.
Now go back and click on Developer Options to enable USB Debugging option like as shown below.
Once you enable the USB Debugging option, it will show the notification message as shown below and click OK to enable USB Debugging.
Now connect your device to the system via data cable and select allow USB Debugging option. After that select Run App option in android studio to run your app from emulator like as shown below.
In case your device connected to the system and if it in online, that will be shown in the emulator window to run the app in a real device like as shown below.
This is how we can enable USB debugging on real device to test or run an android application based on our requirements.
In case if you are not interested to do USB debugging, then we can build an app APK using android studio and install it on a real device to test or run our application functionality.
Open your app in android studio, Go to Build option in menu bar and select Build APK option like as shown below.
After click on Build APK option, our android studio will generate an APK for our application and it will show the APK generated path like as shown below.
Now click on Show in Explorer option, it will navigate you to the APK generated path like as shown below.
Now you can send this APK file to your GMAIL and open that email, install your APK on the device which you want to run the app.
To install third-party APK’s you need to enable unknown app installation permissions in your device. While installing your APK, the device will ask for the permission to install an app on your device.
Once you allow the permission to install APK, your app will be installed in your device to perform your operations like as shown below.
This is how we can run/test our android apps on real devices such as mobile / phone, etc. based on our requirements.