Till now, we have installed android studio, created an android application and learnt about android project structures. We have seen what is AndroidManifest.xml file, res/layout file, build.gradle file etc. We strongly recommend to learn about android project structure if you are not familiar with them.
Once you have created your android application, next step is to test it whether it’s working as expected or not? Will it run properly on real device or not? After all we are developing this application to be used in real device. Is n’t it so?
Having said that, we are now going to learn how to run, test or debug android application.
Getting Started
Now-a-days, there are many ways to run test or debug android application. We can either use –
- Default Emulator Provided in Android Studio
- Genymotion Emulator
- Real Device: We can use real device in two ways –
- Wired connection: Using USB cable. Android Device will be connected with adb host using USB cable.
- Wireless connection: Without using USB cable. Android device will be connected with adb host using wifi
- Online Resources: There are many website which provide online services. e.g. BrowserStack
We will go through each of them one by one.
Run / Debug Using Emulator
we can run test debug android app using emulator.
As per wikipedia,
In computing, an emulator is hardware or software that enables one computer system (called the host) to behave like another computer system (called the guest)
If we want to understand in our context,
Emulator is a software that replicates the features available in real android device so that we can test our android application without actually using real android device. In fact, Emulator contains most of the features present in real device. For example, if you want to test camera feature, you can do it. If you want to test your app above android version 26, you can do it. etc.
How to use emulator ?
There are two ways we can use emulators. They are –
- Emulators provided using Android Studio
- Emulators provided by Third Party
Let’s first go with emulators provided with android studio.
Run / Debug App Using Emulators in Android Studio
Android SDK contains an emulator which uses virtual device, created using AVD Manager, to run any android application. AVD manager manages virtual devices in android studio.
An Android Virtual Device (AVD) is a configuration that defines the characteristics of an Android phone, tablet, Wear OS, Android TV, or Automotive OS device that you want to simulate in the Android Emulator.
We can install virtual devices based on resolution, android versions etc. Visit link to know more about how to run or debug android app using emulators in android studio
Run / Debug App Using Emulators by Third Party
Now-a-days, there are so many third party emulators that we can use to run or debug our android applications. Some of them are –
- Genymotion
- BlueStacks
- LDPlayer
- GameLoop
- NoxPlayer
Some of them have paid services, some are free for personal use. Visit respective sites to learn about their plan or check license etc.
Here, we will be discussing a bit more about Genymotion –
Genymotion Emulator
Genymotion emulator is faster than default emulator provided in android studio. So, it’s better if we use it for development purpose. We can use Genymotion emulator for free if we are using it for personal use. However, if you want their paid service, you can check it out
Run / Debug Android App Using Real Device
In loose term, we can say that emulator imitates real device. It’s not that real device. Also, we can get experience of any app same as that of real device. We can not test many thing on emulator too. For example, touch experience, we can not test touch experience on emulator.
So, after all, we need real device for testing too.
Now, how do we do it?
How can we use our android device to run or debug application ?
We can use our android device in two ways. They are –
Using USB cable (Wired Connection)
In this way, we need USB cable to be able to debug or run android application in device. We connect android device with adb host using USB cable. Then, we run and debug our application in real device. But, it has some limitations. Some of them are –
- It restricts device movement while debugging application.
- We always need USB cable
- Port on device gets damaged overtime
There are many more limitations. So, there is another way in which we can use real device for debugging. It is Using it without USB cable.
Using Wifi Network (Wireless Connection)
In this way, we need USB cable, only one time, for initial setup. Then, we don’t need it. We can run or debug our android application using wifi network. Visit link to know how to run or debug using wifi network.
Run / Debug Android App Using Online Resources
Now-a-days, we have plenty of online resources that provides feature to run or debug android application. In this case, we don’t even need to install emulators or use real android device. We can just use online services to do our job.
That’s it. We have learnt how to run test debug android app.