Skip to content
Home » META » Meta Android Developer Professional Certificate » Introduction to Android Mobile Application Development » Week 2: Emulation and Development

Week 2: Emulation and Development

In this module, you will set up and explore the Android Studio environment.

Learning Objectives

  • Describe emulators and Android OS images and their role in Android app development
  • Demonstrate how to set up and create an emulator in Android Studio, including the role of the Android Virtual Device manager
  • Discuss main activity and manifest code in relation to project structure of Android apps
  • Describe Gradle and its role in project building in Android Studio
  • Outline the folder structure of an Android project in Android Studio and discuss the purpose and contents of related folders and files, including the res and layout folders

Emulators


Video: What is an emulator?

Emulators: Testing Mobile Apps Without Real Devices

This video explains how emulators help software engineers test mobile apps without buying physical devices.

Key points:

  • What are emulators? Software programs that mimic other devices (e.g., phones, game consoles).
  • Purpose: Test apps on various devices without physically owning them.
  • Benefits: Saves time, money, and resources.
  • Resources needed: Adequate storage space and RAM.
  • Types of emulators:
    • Commercial (e.g., BlueStacks)
    • Open-source (e.g., Appetite.io)
    • Gaming (e.g., SNES emulators)
  • Next steps: Learn how to set up and use an emulator in Android Studio.

Overall, emulators are valuable tools for developing and testing mobile apps efficiently.

Imagine you use an emulator to run an Android app you designed on a Windows computer. The emulator will (select all that apply):

Imitate the Android devices your app is designed for

That’s correct. An emulator is a computer program that’s designed to imitate another kind of device.

Allow you to test your app without having to install them on the actual physical devices you designed them for

That’s correct. By mimicking the behavior of the mobile devices you designed your app for, the emulator will allow you to test how your apps will run on these devices without having to install them on the actual physical devices.

Replicate the experience of different hardware or software

That’s correct. The overall goal of emulators is to replicate the experience of the original hardware or software.

Need high computing resources in order to run effectively

That’s correct. For the emulator to run effectively, you need to ensure there is enough storage space and Random Access Memory or RAM available on your machine.

With billions of mobile
devices around the world, the demand for and use of
mobile devices is high as more new devices are released to the market
to meet this demand, software engineers need
to develop apps for them. As you can imagine,
purchasing different types of devices to test these
apps is not practical. That’s where emulators come in. In this video, you will
learn more about emulators, their purpose, as well as the types of emulators available. What exactly is an emulator? An emulator is a
computer program that’s designed to imitate
another kind of device. While different
types of emulators have unique ways of operating, the overall goal
remains the same; replicating the experience of the original hardware
or software. By mimicking the behavior
of mobile devices, emulators allow you
to test how your apps will run on the devices you
have designed them for, without having to
install them on the actual physical devices. For example, if you
are an Apple user and you want to run an app specifically designed
for a Windows computer, you will need to
use an emulator. Emulation does, however, require high computing
resources in most cases. This means that if you are going to use an emulator
on your machine, it’s important to make sure there’s enough storage space and random access memory or RAM available for it
to run effectively. What types of emulators
are available to you? There are several commercial
and open source emulators available for most of the operating systems
in the market. For example, emulators
like BlueStacks, which is a popular
and free emulator, allow you to run Android apps on operating systems
like Mac and Windows. Another example is Appetite io, a browser-based emulator
that allows you to use iOS applications on any PC. Aside from running apps. Some emulators even
make gaming possible. For example, Super Nintendo
Entertainment System or SNES classic console emulators
allow gamers to play old video games on
modern HD televisions. You should now have more
insights into emulator software, what emulators do, and the different types of
emulators available to you. Later, you’ll learn
how to configure and create an emulator
in Android Studio, which will allow you to
simulate your own project app.

Video: Android Virtual Device Manager

Testing Mobile Apps with Android Virtual Devices (AVDs)

This video highlights the AVD Manager in Android Studio as a tool for testing mobile apps on various devices without physical ones.

Key points:

  • Challenge: Testing apps across diverse devices and operating systems.
  • Solution: Android Virtual Device (AVD) Manager in Android Studio.
  • Purpose: Create and configure virtual devices simulating real phones.
  • Benefits: Test apps on multiple devices without physical purchases.
  • AVD Manager features:
    • Create new virtual devices based on desired specifications.
    • Edit and manage existing virtual devices.
    • Launch emulators based on selected virtual devices.
  • Next steps: Learn to create your own emulator using the AVD Manager.

Overall, AVD Manager is a valuable tool for efficient mobile app testing on different virtual devices.

Testing Mobile Apps with Android Virtual Devices (AVDs): A Step-by-Step Tutorial

Developing exceptional mobile apps requires thorough testing across various devices and operating systems. Android Virtual Devices (AVDs) in Android Studio provide a cost-effective and efficient solution, eliminating the need for physical devices. This tutorial guides you through creating and using AVDs to test your mobile apps.

Prerequisites:

  • Android Studio installed and configured with the Android SDK.
  • Basic understanding of Android development concepts.

Steps:

  1. Open the AVD Manager:
    • Launch Android Studio.
    • Click on Tools > Android > AVD Manager.
  2. Create a New AVD:
    • Click the + Create Device button.
    • Select a Phone, Tablet, or Wear OS device category.
    • Choose a device profile that resembles your target device.
    • Customize hardware configuration (RAM, storage, etc.) as needed.
    • Assign a name and click Next.
    • Select an Android platform version compatible with your app.
    • Optionally, adjust hardware virtualized features.
    • Click Finish to create the AVD.
  3. Launch the Emulator:
    • Select your newly created AVD from the list.
    • Click the Play button (green triangle) to launch the emulator.
    • This will open a virtual Android device on your screen.
  4. Deploy and Test Your App:
    • Run your app in Android Studio, targeting the created AVD.
    • Interact with the app on the virtual device to test its functionality, performance, and UI across different screen sizes and resolutions.
    • Utilize Android Studio’s debugging tools to analyze app behavior and fix issues.
  5. Manage Existing AVDs:
    • The AVD Manager displays a list of all created virtual devices.
    • You can edit their configurations, duplicate them for different testing scenarios, or delete unused ones.

Additional Tips:

  • Create multiple AVDs targeting different device profiles and Android versions for wider coverage.
  • Use the AVD Manager’s search bar to quickly find specific devices.
  • Consider using cloud-based testing platforms for large-scale testing across diverse devices.
  • Explore advanced AVD features like camera simulation and network throttling for comprehensive testing.

Remember: While AVDs are powerful tools, physical device testing is still important for real-world performance evaluation and user experience validation.

By following these steps and incorporating best practices, you can leverage AVDs to effectively test your mobile apps and deliver high-quality experiences to users across various devices.

Which option best describes what the Android Virtual Device Manager is used for?

It lets you define the various features of a virtual device.

That’s correct! The AVD Manager lets you create and configure virtual devices, enabling you to define the various features of those devices.

Although software testing has long
been an integral part of the overall software development cycle, mobile app
testing is gaining more attention. So how is it possible to test and
optimize all these different mobile apps developed for
different devices and operating systems. Well, in this video you’ll learn
about a feature of android studio that can help you with this,
the android virtual device or AVD Manager. You can use the AVD manager to ensure
that android apps are well optimized for different devices. More specifically, this tool allows
you to define the various features of a physical device, such as an android
phone that you want to create and simulate in the android emulator. By creating and configuring these
virtual devices, you can test your apps across multiple devices without
necessarily purchasing physical devices. Now let’s take a moment to explore
the AVD Manager available from the android studio, IDE, or
integrated development environment. In this video, I’m going to introduce you
to the android virtual device manager or AVD interface. I’ll start by opening Android Studio. To access the A V D interface. I go to the top right of
the android studio environment and click on the three dotted menu for
more actions. Then I select virtual device manager. This opens a new window on this page. There are two major features. You can create a device and you have
access to a list of previously created virtual devices with each virtual device
listing which includes the device name and android version, also referred to
as a P I level, you can perform various actions as indicated by
the icons on the upper right hand side. For example, if you click the play button, it will run the emulator
on the virtual device. You have selected you can edit the device
by clicking the pencil button. This allows you to edit and save any
changes you make to the properties of the virtual device with
the help of the device editor. There are also additional action options. If you click on
the triangular dropdown menu, these actions range from duplicating
to deleting a selected virtual device now to create a new device,
you can click on the create device button. Once again this opens a new window here. You can create and configure a new virtual device based on
your specifications and requirements. You’ll be able to select the physical
device you want to emulate and set and edit any required properties and that’s an overview of the major
features of the A VD interface. From launching an emulator on an existing
virtual device to creating new ones. You’ve now had the chance to preview some
features of the A VD manager interface. Later you will learn how to use the A V D
manager to create your own emulator.

Reading: Setting up emulator software

Reading: Mobile CPU architecture

Reading

Video: Operating System Images

Summary of Android OS Images and their role in development:

What are Android OS images?

  • Copies of different Android operating systems used by emulators.
  • Allow developers to test their apps on various OS versions (from older, like Lollipop, to the latest, Tiramisu).
  • Accessed through API levels that reflect new features available in specific OS versions.

Benefits of using OS images:

  • Leverage features of any Android OS in the market.
  • Test app compatibility with different versions.
  • Enjoy built-in features through the API provided by each OS image.

How to access OS images in Android Studio:

  1. Open Virtual Device Manager (three dots menu > Virtual Device Manager).
  2. Create a new virtual device (phone category).
  3. Choose a device definition (e.g., Pixel 2).
  4. Select the desired OS image based on the API level you need (download if not already available).

What’s next:

  • Learn how to use the OS image to run an emulator and test your app.

Additional notes:

  • The summary focuses on key points about OS images and their role in development.
  • The provided information accurately reflects the content of the original text.

Tutorial: Understanding and Using Android OS Images in Development

Android OS images play a crucial role in developing and testing apps across various Android versions. This tutorial will guide you through what they are, their benefits, and how to access and use them within Android Studio.

What are Android OS Images?

Imagine you want to test your app on the latest Android features, or ensure compatibility with older versions. That’s where Android OS images come in. They are essentially complete copies of different Android operating systems, specifically designed for use within emulators. These images allow you to run and experience different Android environments without needing physical devices.

Benefits of Using OS Images:

  • Test on Various Versions: No need to own numerous physical devices. Install different OS images to test your app’s functionality and compatibility across various Android versions.
  • Leverage New Features: Get hands-on with the latest features introduced in newer Android versions by using their corresponding OS images.
  • Built-in Features: Access the functionalities and APIs specific to each OS image, enriching your app development process.

Accessing OS Images in Android Studio:

  1. Open Virtual Device Manager: Launch Android Studio and click the three-dot menu in the top right corner. Select “Virtual Device Manager.”
  2. Create a Virtual Device: Click “Create Device” to open the configuration window. Choose “Phone” as the category.
  3. Select Device Definition: Pick a device you want to emulate (e.g., Pixel 2).
  4. Choose OS Image: Scroll down to the “System Image” section. This displays available OS images with their corresponding API levels.
  5. Download and Install: If the desired image isn’t available, click “Download” to initiate the download. Once downloaded, select the image and click “Next.”

Tips:

  • Consider your app’s target audience and API level requirements when choosing an OS image.
  • You can create multiple virtual devices with different OS images for diverse testing scenarios.
  • Remember, newer OS images often require more powerful emulator configurations for smooth performance.

Beyond the Basics:

This tutorial serves as a starting point. As you progress in your development journey, delve deeper into:

  • Creating Custom OS Images: Tailor emulated environments to specific testing needs.
  • Advanced Emulator Configurations: Optimize memory, storage, and other parameters for efficient testing.
  • Integration with Continuous Integration/Continuous Delivery (CI/CD): Automate testing across various OS images as part of your development pipeline.

By understanding and utilizing Android OS images effectively, you can streamline your development process, ensure comprehensive testing, and deliver high-quality apps compatible with various Android versions.

What is a version or copy of an Android operating system (OS) that is used by an emulator called?

Android operating system (OS) image

That’s right. Android OS images are versions of Android operating systems that are used by an emulator.

With the release of each new
Android operating system comes need changes that offer security and performance
improvements and enhance the user experience
of Android as a whole. To make sure your app users
have the best experience is essential to understand
the dynamics of different operating systems. That’s why in this video you will be
introduced to Android operating system or OS images and their
role in development. Android OS images
adjust versions or copies of Android
operating systems that are used by an emulator. With the help of these
Android OS images your app can leverage the features of any operating system
in the market. For example, if
you wanted to test the most recent
releases you could download the most
recent Android OS image and run it on the emulator
to experience the OS. Likewise, if you wanted to test your app against an
older OS you could, for example, download the Android Lollipop
system image and run that. As a developer, through the OS images you can enjoy
the built-in features of an operating system using the application programming
interface or API level. This is a whole value like
API level 30 that uniquely identifies new features that have been released
for a particular OS. As the number increases more
functionalities are added. Currently the most
recent Android OS images available for developers in Android Studio range
from version 8, code name Oatmeal
Cookie released in 2017 to version 13,
code named Tiramisu. More specifically, after the
release of Oatmeal Cookie in 2017 came Pistachio
Ice Cream in 2018, Quince Tart in 2019, and Red Velvet Cake in 2020. These were followed
by Snow Cone in 2021, Snow Cone V2 in March
2022, and Tiramisu. With each release
of a new version the API level increases with the most recent OS image
having the highest API level. Now that you know more
about the OS images, let’s explore how to access
them in Android Studio. In this video, I’m going
to demonstrate how you can access Android OS images
on Android Studio. In the welcome to
Android Studio window, click the “Three
dotted menu icon” on the upper right-hand side
to access more actions. Then click on the
“Virtual Device Manager.” On the Device Manager page,
click “Create Device.” This opens the virtual
device configuration where you can
create an emulator. You can choose from the
different device categories. But let’s continue with phone. You can then choose
a device definition. The different devices
are listed with information on things like
their size and resolution. Let’s pick pixel 2
and click “Next.” This is where you have
access to your OS image. Once you select a device
definition you must then specify what type of image you want to
install for that device. On this page you have access to many images of
operating systems, which are like copies of the
different operating systems, such as API level 33. If the target of your
app is Android API 33, if you click on
“Download” next to the release name of your
chosen system image, it will download
the selected OS. That’s how you can access system images in Android Studio. Later you will learn how to use your system image to
run an actual emulator. You have now learned about Android OS images and
how to access them in Android Studio
preparing you to use an OS image to run your own
app through an emulator.

Reading: OS versions and images

Reading

Video: Configuring an emulator

This video tutorial guides you through configuring and launching an Android emulator in Android Studio.

Key points:

  • Configuration:
    • Use Android Virtual Device (AVD) to specify device properties like name, orientation, memory, and storage.
    • Define the desired device type (phone, tablet, etc.) and Android system image (operating system version).
    • Advanced settings allow customization of RAM, internal storage, and SD card storage.
  • Creation:
    • Access the Virtual Device Manager from Android Studio’s welcome window.
    • Click “Create Device” and choose the desired device category and specific device.
    • Select the system image (operating system version) and customize name and other settings.
    • Click “Finish” to create the AVD.
  • Launching:
    • Select the AVD in the Device Manager and click the “Play” button.
    • The emulator will launch in a separate window, mimicking the chosen device and Android version.

Benefits:

  • Emulators provide a safe and controlled environment for testing and debugging Android apps.
  • They offer valuable insights into the app’s behavior on different devices and operating systems.

Remember:

  • This is a fundamental skill for Android app development.
  • Future videos will cover app installation and more advanced emulator functionalities.

When configuring an emulator using the Android Virtual Device (AVD), what are some of the properties you can set? Select all that apply.

Specify what you want the device to be called.

That’s right! The first property you can set is the AVD name. This lets you specify the name of the device you want to create.

Select landscape or portrait mode.

Correct! With the startup orientation property, you can set the device’s orientation to landscape or portrait.

State the number of processor cores that are to be used for the emulated device.

Spot on! With the emulated performance property, you can specify how many processor cores you would like to use for the emulator. The more processor cores you use, the faster the emulator.

Override the default RAM value.

Well done! You can specify a new RAM value to increase the emulator’s available memory.

because running an app on an emulator
is much like using an app on an actual mobile device,
most developers are turning to emulators as a tool to test and
even debug their app code. While emulators are a safe
place to test code, especially at the beginning
of the design phase. Using an emulator on a computer
does require some configuration to function properly. That’s why in this video you will learn
how to configure and launch an emulator. You can configure an emulator with the
help of the android virtual device or a V. D. In android studio in
particular with the A V. D. You can specify the interaction between
the development computer and the emulator. Let’s explore some of the Aivd
properties you are most likely to use when configuring your emulator in
android studio the first is the A V. D.
Name. You can use this to specify the name
of the device you want to create. Then there’s startup orientation which
sets the orientation for the device. You can select either landscape or
portrait mode. Another property you are likely
to use is emulated performance. This allows you to specify the number
of processes cause from your computer’s hardware that you’d like
to use for the emulated device, the more process cause you
use the faster the emulator, you can also set the RAM or random
access memory in memory and storage, which is an advanced setting, although
the manufacturer sets around value for the device by default,
you can override this by specifying a new round value as a note
the higher the round value, the more resources the device
will consume on your computer. Now that you know some more about
the Aivd properties you may encounter when configuring an emulator. Let’s explore how to configure and create an emulator in
android studio in this video. You’ll learn how to configure
an emulator in android studio in the Welcome to android studio window. Access the virtual device manager by
clicking the three dotted menu in the upper right hand corner,
then clicking on virtual device manager. Although there are existing
devices to choose from, click create device on the top
left to create a new one. This will open the virtual device
configuration window where you can choose the type of device you want to emulate. You have different device categories
available to you including tv phone, wearables, tablets, and automotives. However, for this video,
the focus is phones. You can select pixel two XL and
then click next on this page you need to select the system image
you want your device to run. This is a copy of an android operating
system that is used by an emulator. A system image called API 32
is already downloaded Although you have the option to download others. Let’s use API- 32 for
the purpose of this demonstration. So click A P I 32 followed by Next This
takes you to the android virtual device or a V D page where you can verify
the configuration of the device, you can name the Aivd whatever you’d
like using the change buttons. You also have the option
to change the device and system image that you
selected earlier on Next. You can choose to make the device
portrait or landscape. Then you have the advanced
settings which allow you to customize many more properties. This includes the option
to specify the RAM, you want the device to run
on the internal storage and even the additional memory and
storage from an SD card. All devices in the market
have these features, although these settings can be changed for
this video, let’s use the values already
assigned here by default and that’s an overview of how
to configure your emulator. You can then click finish to create it. The pixel two XL emulator is now
available in the device manager. To run the emulator,
click on the play button, you may need to wait a few moments
as it launches the emulator. The emulator pops up in a separate window. It looks exactly like an actual
device because the android system image allows you to
experience the look and feel of any android device available to
you in the market, which is incredible. So here’s your emulator device with
different apps running on this system Image in subsequent videos. You’ll learn how to install
your own apps on this emulator, you should now know how to configure and
launch an emulator. This is an essential skill for
android mobile app development as you will likely use emulators to test and
debug your own apps in the future.

Reading: Common libraries and packages

Reading

Practice Quiz: Knowledge check: Development Environment Setup

Which of the following allows developers to configure an emulator to start up as if a user is turning a device on for the first time?

When setting up an emulator on Android, which section gives you options to configure the device RAM?

True or False: Android Studio allows you to install HAXM through its SDK manager.

Which of the following allows developers to enable the last state option of an emulated device?

What alternative hardware acceleration tool can be used for running an emulator?

Reading: Additional resources

Reading

Android Studio IDE and project structure