Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
There are many options when creating a virtual device. This video covers the process of creating a virtual device as well as how to run it in the emulator.
Resources
- Network Speeds and Latencies
- Managing Virtual Devices From the Command Line
- Emulator Keyboard Shortcuts*
*The Mac shortcuts for rotating are fn+ctrl+F11 and fn+ctrl+F12
[SOUND] Hi, my name is Ben and welcome to
0:00
getting started with the Android emulator.
0:04
In this workshop, we're going to become
experts at using the Android emulator.
0:10
The first thing we'll need to
do is set up a virtual device.
0:15
A virtual device is set of hardware and
software options
0:19
which tells the Android emulator what
sort of device we would like to emulate.
0:22
If you've recently
downloaded Android Studio,
0:27
you may already have an appropriate
virtual device created for you.
0:29
However, you might still want to follow
along to see how to create your own.
0:33
Before we create our virtual device,
0:37
we'll want to make sure that
we have HAXM installed.
0:39
HAXM is hardware acceleration for
the emulator.
0:42
With HAXM, the emulator runs
much quicker than it used to.
0:45
We can check if HAXM is installed
by opening the Android SDK manager,
0:48
clicking on the SDK Tools tab, and looking
for a checkbox next to the HAXM entry.
0:57
If HAXM isn't installed, go ahead and
1:06
install it by checking the box on
the left and then clicking apply.
1:08
Once we verify that HAXM is installed we
can go about creating our virtual device.
1:13
We can create and
1:18
manage our virtual devices in
the Android Virtual Device Manager.
1:19
Let's click on the AVD Manager to open it.
1:23
Then, click on Create Virtual Device
to begin the setup process.
1:27
The first choice we need to make is
what hardware we would like to use.
1:33
We can pick from the list of
default hardware profiles or
1:37
we can create our own.
1:40
Let's click on new hardware
profile to get an idea
1:42
of what we're really choosing here.
1:45
It looks like it's just picking the
hardware features of our virtual device,
1:48
like what resolution it is,
if it has a front facing camera, and
1:52
what sensors does it have.
1:57
This would be real useful if
we wanted to emulate a device
1:59
that wasn't on the previous list.
2:02
However, for our purposes the Nexus 6
device definition will do just fine.
2:04
So let's select the Nexus 6 and
then click Next.
2:09
Next we need to pick a system image for
our device.
2:14
The system image represents which
version of Android we want to have
2:18
on our virtual device.
2:21
An important note is that we can only
utilize HAXM on an x86 system image.
2:23
x86 is the type of processor
your computer normally uses,
2:29
whereas ARM is typically
used on mobile devices.
2:34
Since we're running
the emulator on a computer,
2:39
It will be faster to use
the x86 system image.
2:42
Another thing to mention is the target.
2:46
You may have noticed that some of the
targets contain the phrase Google APIs.
2:48
If we pick a target with Google APIs,
2:53
our emulator will come preloaded with
the Google APIs, such as Google maps.
2:55
Let's pick a Marshmallow x86
system image and click Next.
3:01
Lastly, we have several customization
options for our virtual device.
3:06
We can set its starting size and
orientation along with whether or not
3:10
it will show a frame around our virtual
device to make it look like a real phone.
3:16
If we click on Show Advanced Settings,
another option that we have access to
3:20
is setting the source for
the cameras on our virtual device.
3:24
We can choose to not have a camera and
3:29
opening the camera will
crash the camera app.
3:32
We can have an emulated camera which will
display a default image in our camera,
3:35
or if your computer has
a webcam you can choose for
3:40
the webcam image to display
as the camera image.
3:43
I'm going to leave these both as emulated.
3:46
Also, if you're making an app that
relies on a network connection,
3:50
you'll probably want to test how it
works under various network conditions.
3:54
We can set many different networks speeds,
and
3:58
latencies to make testing
much more comprehensive.
4:02
The last important thing to mention
here is that we want to make sure that
4:07
the Enable keyboard input box is checked.
4:10
This lets us type with our physical
keyboard instead of having to
4:13
use the virtual device keyboard.
4:16
Now we can hit Finish, And
4:19
click the Play button next to our
virtual device to test it out.
4:23
Looks great.
4:38
Let's quickly go into the camera app and
see what the emulated camera looks like.
4:39
Hey, that's kind of neat.
4:46
Let's take a picture of it.
4:47
Another way we can launch our virtual
device is by choosing it in the run debug
4:54
configurations.
4:59
Let's click on our app and
select edit configurations, and
5:01
under target devices down here,
5:05
let's select emulator and then pick our
virtual device as the target device.
5:08
Now when we run our app,
it will start directly in the emulator.
5:15
And if the emulator isn't running
it will start automatically.
5:19
Awesome.
5:23
You need to sign up for Treehouse in order to download course files.
Sign up