-
Book Overview & Buying
-
Table Of Contents
How to Build Android Apps with Kotlin - Second Edition
By :
As a part of installing Android Studio, you downloaded and installed the latest Android software development kit (SDK) components. These included a base emulator, which you will configure to create a virtual device to run Android apps on. An emulator mimics the hardware and software features and configuration of a real device. The benefit is that you can make changes and quickly see them on your desktop while developing your app. Although virtual devices do not have all the features of a real device, the feedback cycle is often quicker than going through the steps of connecting a real device.
Also, although you should ensure your app runs as expected on different devices, you can standardize it by targeting a specific device by downloading a device profile, even if you don’t have a real device if this is a requirement of your project.
The screen you will have seen (or something similar) when installing Android Studio is as follows:
Figure 1.4 – SDK components
Let’s take a look at the SDK components that are installed and how the virtual device fits in:
With this knowledge, let’s start with the next exercise of this chapter.
We set up an Android Studio project to create our app in Exercise 1.01, Creating an Android Studio project for your app, and we are now going to run it on a virtual device. You can also run your app on a real device, but you will use a virtual device in this exercise. This process is a continuous cycle while working on your app. Once you have implemented a feature, you can verify its look and behavior as you require.
For this exercise, you will create a single virtual device, but you should ensure you run your app on multiple devices to verify that its look and behavior are consistent. Perform the following steps:
Figure 1.5 – The Android Studio toolbar
app is the configuration of the app that we will run. As we haven’t set up a virtual device yet, it says No devices.
Figure 1.6 – Device Manager in the Tools menu
Figure 1.7 – The Device Manager window
You will then be presented with a screen, as shown in Figure 1.8:
Figure 1.8 – Device definition creation
Figure 1.9 – System Image
The Tirimasu name displayed here is the initial code/release name for Android 13. Select the latest system image available. The Target column might also show (Google Play) or (Google APIs) in the name. Google APIs mean that the system image comes pre-installed with Google Play Services.
This is a rich feature set of Google APIs and Google apps that your app can use and interact with. On first running the app, you will see apps such as Maps and Chrome instead of a plain emulator image. A Google Play system image means that, in addition to the Google APIs, the Google Play app will also be installed.
Figure 1.10 – Virtual device configuration
Figure 1.11 – Virtual devices listed
Figure 1.12 – Virtual device launched
You will then see the virtual device running within Android Studio in the Emulator tool window. Now that you’ve created the virtual device and it’s running, you can go back into Android Studio to run your app.
Figure 1.13 – App launch configuration
This will load the app into the emulator as shown in Figure 1.14.
Figure 1.14 – The app running on a virtual device
In this exercise, you have gone through the steps to create a virtual device and run the app you created on it. The Android Virtual Device Manager, which you have used to do this, enables you to create the device (or range of devices) you would like to target your app for. Running your app on the virtual device allows a quick feedback cycle to verify how a new feature development behaves and that it displays the way you expect it to.
Next, you will explore the AndroidManifest.xml file of your project, which contains the information and configuration of your app.