How to create a virtual device to emulate your Apps - Technology
Pular para o conteúdo

How to create a virtual device to emulate your Apps

Adverts

In previous entries we built a first Android project and reviewed what the directory structure that is generated with the project consists of, in this
On this occasion we will see how to launch our application directly on an emulator or virtual device.


These devices are known as Android Virtual Device (AVD) and basically consist of emulators that we create and configure according to our needs regarding the type of device whether it is a cell phone or tablet, screen size or density, characteristics, operating system version, memory among other elements that may be important for our application.

Android Studio includes its own emulators, which we must download and configure, although this is not the only alternative, as we can include third-party emulators or simply run the application on physical devices, this last alternative is ideal, as we check directly on the device and the resource consumption depends on it, while if we use emulators we must assign pc resources to the emulator as they behave like virtual machines that require a high consumption of RAM memory, however, it is good to have these two alternatives.

Creation of a Cell Phone Emulator.

 

If an emulator has already been created in Android Studio, then the name of the virtual device will be displayed in the top left corner, in this case, as mentioned in previous posts, we have created an emulator API 28 Pixel 2which is already selected and ready to run the application.


If you want to create another one, we can enter the option Device Manager from where we will see the created emulator and can modify it, or click on “Create device” to create a new one.

If, on the contrary, it is the first time that you are creating an Android Studio emulator, you will see that in the upper left corner an option appears indicating that there are no devices (No Devices) and if we display this option we find 3 options, from where we can enter “AVD Manager” or the same icon in the top bar as shown in the image.


Clicking on the option loads the same screen we showed earlier, but in this case there are no emulators created and instead they give us the option to create one.


Clicking on create loads a window where we see the different categories for creating emulators such as TV, Cell Phones, Watches, Tablets, among others.

 

From here we select the “Phone” option and choose one of the available ones, there we can see the name of the device, if it has Google Play (important for resources that require Google APIs), size, resolution and screen density, In this case, we will choose “Pixel 2” and we will click Next.


 

When we do this, another window is loaded from where we must download the image of the version of the operating system we want to work with. If there are images previously downloaded, they will be displayed here, but in this case we see that there are none (it is very important that we are connected to the internet, otherwise this process could not be carried out to download, after that it is not necessary) , we click on Download of the option we want, for example, as seen in the image, we download “android Pie”


When doing this, another window is loaded where we must accept the usage license and click Next

The virtual device download and installation process starts automatically, this may take a while depending on your internet connection.


When finished and finished, we return to the previous window where we already see the downloaded image, select it and click Next


We see how a new window is now loaded where we define the emulator settings in terms of name, screen orientation and advanced options where the amount of allocated RAM can be assigned manually, if memory usage is simulated externally among other features, then we click Finish.


When we do this, we see that our emulator is already associated and the device is loaded in the “Device Manager” section as shown at the beginning of this guide.

If we want, we can launch the emulator directly or click on the “Device Manager” side tab to hide it (not necessary) and click on the RUN icon at the top.

 

this launches the emulator and displays our application, this process may take a while the first time when the setup process starts, after this the emulator is expected to be much faster from now on.


If we want to create a new emulator, we go back to Device Manager and click on Create Device


When doing so, we repeat the previous steps, for example, we can create a tablet and at the end we will see that the new emulator is loaded and when we display the options we will find all the emulators created.


If we enter the Device Manager again, we will see both emulators and from there we define which emulator to use to test our application, being able to launch it directly in each emulator or by selecting it at the top and running the application directly

By doing this, the emulator is loaded and we can also see how each emulator run is separated into tabs.

Emulator display.

 

Previously the default emulator loaded as a separate window, currently by default it is included in the Android Studio interface on the left side, however we can place it anywhere or remove it if we want it to float and, So, move an external screen so that it is independent of the IDE.

 

To minimize the emulator we can click on the “Emulator” side tab and show it again by clicking on it again.


 

If we want to change the position, we right-click on “Emulator” and we see different options, in this case we select “Move to” and define the desired location.

If we now want to make the emulator floating, then we select “Display mode” and the “Float” option

Thus, we have the emulator as a separate window from the development environment.


And with that we have already created and configured virtual devices with which we can test our first application.

 

It may also interest you.

 



Is there anything you want to add or comment about this entry? feel free to do….And if you liked it... I invite you to share Y Subscribe by clicking on the “Join this site” button to hear more posts like this one 😉