How to test Android Applications without Emulator
Today we are going to see how we can test our android applications instead of using emulator we can use our real device.
To use the real device for testing we need to connect our device with our pc, to do that we have 2 choices. The first choice is by using USB cable we can connect our real device to pc and the second method, which is my favorite, that we can connect our device wirelessly (No use of USB or any cable).
Let’s see how we can do these methods one by one.
To perform these methods first we need to enable USB Debugging from the developer options.
Go to the system settings and go at the last there is an option called developer option like below.
If there is no option is showing then you have to unlock this option by going to about phone option then click on software information and then click quickly 5 to 6 times on build number label. Now you able to see the developer option.
After clicking the developer show scroll down to the USB Debugging option.
If it is not enabled then click on it and enable it.
Now we are ready to go ahead.
Run Application using the USB cable
To run an app on your device connect you USB to your phone and then open your android studio.
After connecting your phone to your system via a cable. Hit the run button in the Android Studio and pop will be shown on your mobile screen. Click on allow to allow the installation of app by your computer system.
After doing that, wait for some time after the build your app will be launched successfully and you can see all the logs of the device in the logcat.
Now, this the part where we use a USB cable to test the app now see the second method.
Run an Application without a USB cable (wirelessly)
To run your app wirelessly on your device, you must connect your device on the same network where your system or pc is connected.
That means you must be on the same local network or wifi.
So now I am assuming that both the device mobile device and computer system are on the same network.
To use your mobile phone wirelessly we need to enable ADB on our mobile device.
To do that we need to open our platform tool folder in the file explorer.
If you are using windows then you have to go to this directory.
Or if you are using Linux or Mac then go to where you install your Android SDK and there will be a folder named as platform-tools.
After opening the directory, we need to open a terminal on that path. If you are on windows, click on the address bar and type cmd and press enter. This will open cmd in that location.
If you are on Linux or Mac, you can use the cd command.
Now to need USB cable only one time to enable adb in your device.
So, connect your device via USB cable and then type this command in that terminal or cmd- adb tcpip 5555
Press enter and wait to finish the execution of the command.
After completing the commands, remove your USB cable.
Now we need the local IP address of the device. Go to the wifi settings in the system settings and click on your connected wifi this will show the local IP address of your device.
After getting the IP address, in my case it is 192.168.0.110, type this command in your terminal- adb connect <ip_address_of device>
After hitting the enter your device will connect successfully with your pc wirelessly and your device will show in the android studio as is was shows when you were connecting your mobile via USB cable.
Now run your app and it will install and launch your app wirelessly.
Bonus tip: If you are not connected on wifi then you can use your mobile hotspot and the IP of your mobile will be 192.168.43.1. Use this IP address of your mobile to connect.
Now, this comes to the end of this tutorial. Hope you learn something new. If yes then do share this article with your friends and mates and tell them this awesome trick.
Have a nice day.