In the previous video
we set up our Hello World application
and what I want to do now is take you through
setting up the emulator, so that when we get to
the next video we can run this application.
Now, Android Studio should have set up an emulator
for you when you installed it.
But I want to go through and show you
how to do that again anyway.
And that's because it's useful to know create new emulators
so that you can download and test on different
Android versions when you're going to release your app.
So to get to the Android virtual device manager,
you can either either click on this little button over here.
Alternatively, you can click on Tools, Android,
and select AVD manager.
You can see that I've got a Android virtual device
already set up, but I'm gonna delete that, as I mentioned,
and walk through the process of creating it again.
So, I'm gonna click on this little triangle
that's on the far right, and that's because it's a menu.
And from there, when I click on it, I can select delete,
and click on yes.
Now, if you've got everything deleted, like I have,
you'll start off with a screen that looks like this.
So let's come down here and click on Create Virtual Device.
And I'll just expand this a little bit bigger,
so I can see it a bit better.
Now, I'm going to choose the Nexus 5X here
for a few reasons.
Firstly, it's a good one for testing purposes.
And secondly, it's the device that,
the physical device that I actually own.
Now, if you're a bit short on memory,
or you've got a slow computer,
then you may be better off with something like the Nexus 4
that uses less resources.
And this Play Store column is actually quite important
because it tells us which devices can access the
Google Play Store.
Now, at the time I'm recording this I need a Nexus 5,
and the Nexus 5X emulators are able to download
apps from the Play Store.
Of course, that might change over time.
Now, there are a couple of implications of that.
The first one is that you can't instal apps from
the Play Store on other devices, the Nexus 4 for example.
But that's not normally a problem,
because you usually use the emulator for
testing your own apps,
and we'll touch on that a little bit later.
Now, another implication is to deal with route access.
But don't worry about that at the moment,
just be aware that there are things you can't do
on the Play Store emulators.
That's something else we'll discuss later in the of course.
Once you've selected a device, click on next.
So again, I'm selecting the Nexus 5X.
And this next screen lets you choose
which system image to use.
And you can see at the top there's three tabs here.
The first one is the recommended devices
and you can download the images from here
using the download link.
So if I wanted to select the API 24 version,
I could just click on download there.
That would download, and then I would be able to
access that, and use that.
But in my case, you can see we've got one that
hasn't got the download option, and that means that
it's already been installed on this computer.
You'll note that these devices over here to the right
on the target have got Google Play in the target name.
If we'd chosen a different model of phone
on the previous screen, the target names probably
wouldn't include Google Play.
And this little tab up here for x86 images
and also one for other images.
Now, the x86 images does give you a lot of choice,
but the decision's quite easy when you're starting off.
Now, the easy one is if you're running Linux.
If that's the case, you just choose an x86 image
for Android O, Oreo.
So you would choose this one if you're running Linux.
You don't have to worry about HAXM or anything like.
And if you've gone through the earlier video of checking
and configuring of visualisation support, and you buy us,
then there's really nothing more to be done.
Linux will happily use the x86 system images.
Now, if you're running on a Mac or Windows
then the x86 images will give the best performance,
provided you manage to get HAXM installed.
Now if you did, then you're in the same position as
Linux users, so again, choose an x86 image.
Now, if you're on Windows or Mac without HAXM
the x86 emulators won't run,
but will refuse to start because HAXM isn't available.
So, in that case, you should use the other images
to use an ARM image.
Now, all modern Mac's can run HAXM
although you may need to instal the latest
updates on your Mac.
So, if you didn't manage to instal HAXM
sort that out before continuing now.
For Windows you can only instal HAXM if your computer
has an Intel processor, and supports virtualization.
So, if you've got an AMD processor, unfortunately you'll
have to choose the armeabi-v7a image
from the other images tab.
Now these system images, these ARM system images,
are unfortunately a lot slower than the x86 ones.
So, only use these if you've got no other choice.
In fact, it's worth checking out the Genymotion emulators
instead, because these ARM images set in Android Studio
are very slow indeed.
Now, I'm gonna add a link to the Genymotion website.
It's available at genymotion.com.
So we'll quickly have a look at this Genymotion website.
Paste that in, and this link will be in the
resources section of this video.
There's an option over here to click in
the top right called Trial.
So if I click on that, you'll be asked to register
before you can actually download anything.
Once you've registered, you need to find the link
for the personal version.
At the moment, that's on a button when you scroll
down the page, but that way well change,
so be prepared to hunt around the site to find it.
But, again, that's only if you can't get
some of these other system images to work.
So, going back to Android Studio.
If you can use the x86 system images that
come with Android Studio, then I certainly
recommend that you use them.
Otherwise, check out the Genymotion emulator if you find
the ARM system images are too slow.
Now, if you're happy with working at the command prompt
I'm gonna be putting some instructions on
how to use the x86 emulators from a command prompt.
Then I'm gonna let you run them on Windows without HAXM
and it gives better performance than the ARM system images.
But we'll add a document to the FAQ section
explaining how to do that.
Okay, so back to the x86 images.
So I'm going to use the Oreo image, API 26.
The target here is Android 8,
Google API, as you can see there.
So note that Google APIs isn't the same thing
as Google Play.
So this emulator won't be able to
access the Google Play store.
So that's fine, I'm going to using this
emulator for most of the apps in this course.
But we will be installing a Play Store emulator
for the YouTube app a little bit later.
So, if you've got this option here, and there's a download
link, you'll need to click it at this point.
In my case it's already downloaded, so I can just click on
next after making sure that the Oreo version API level 26
is selected, clicking on next.
Now, it's here that we get the chance to change
the configuration, and you've got a few options here.
So I'm gonna go through and explain what they are.
Firstly, the AVD name.
Now, you can change that to something else if you want to,
but the suggested name is pretty good
unless you create a lot of emulators.
Then it's a good idea to use a name that describes it
a bit better, so you know what all your
Nexus images are, for example.
The default name's fine here,
so I'm just gonna leave it as that.
Alright, so there's another chance here to choose
a different device by clicking the change button.
And I could also choose a different version of Android
if I had the images downloaded.
And that'll just show a screen similar to
the previous one, so I'm gonna leave them both as they are.
And this next section down here, you can actually choose,
you can change the orientation,
but you can also do that while the device is running.
So if you've created a tablet instead of a phone,
then landscape would make more sense as the default
orientation rather than portrait.
Now the emulated performance down here,
that's gonna let you use the host's GPU,
the graphics processing unit,
which can speed up the emulator display quite a lot.
But it can also cause problems with some systems though.
So it's best to leave it as I've got it on automatic
to start with, but if you do get GPU or GL errors when
running the emulator, then come back here and change
it to software instead.
And that prevents the emulator from attempting to use
your graphics card processor if there are problems.
Now, also try software if your emulator hangs
and doesn't fully start up.
Sometimes that fixes the problem.
Now, if HAXM isn't installed on Windows,
then select software.
Without HAXM, hardware often doesn't work.
The emulator isn't always good at detecting that,
so it's best to set it explicitly here in that scenario.
And this device frame, that looks nice on the screen,
so I'm gonna leave that ticked.
It's really just eye candy though, so on slower machines
it's probably worth un-ticking to save for some resources.
And the show advanced settings button lets you configure
things like the amount of RAM to allocate for the emulator.
If I click on that and have a look,
scroll down a little bit, you can see that
currently it's defaulting to 1,536 megabytes,
that's one and a half gig, that the emulator will use
from your system resources.
So on a four gig system, you're gonna give a lot of
memory to the emulator.
You might want to knock that down a lot in that scenario.
One gig or even 768 meg might work better
on a system with low memory.
Now the VM heap is needed for the Java runtime
on the device, the emulator, and comes out of the
total memory that you've allocated.
Now internal storage uses a file on your hard drive,
so this 800 megabytes here isn't coming out of your memory.
There's not really anything gained from increasing it,
so unless you intend to instal hundred of apps on the
emulator, I'd say leave it unchanged.
And specifying an external file for the SD card is an
advanced thing to do, and there's not much point in
changing that at this stage either.
You do that if you wanted to sort of pretend you're
taking it out of the emulator and plugged it into
your computer, like you could do with a real SD card.
But that's not something we're
gonna be doing in this course.
Now, when I clicked that show advanced settings option,
the device frame options moved.
You can create custom skins for the emulator.
That's just eye candy, really, but
it can be useful when you've to publish your app
because you can capture a screenshot of it
running on an emulator,
and obviously that'll look better if it looks like a
real device, rather than just a square box.
So when the time comes for you to publish apps on the
Google Play Store, then certainly play around
with skins if you want.
This is the section I'm talking about down here,
but we're just starting out so either just accept
the ones suggested that I'm gonna do,
or you can un-tick enable device frame if you want to
speed things up a little, and give your computer
less work to do.
So, finally, down here there's this option
for enable keyboard input.
Well that box lets you use the computers keyboard
to type into the emulator.
So that's quicker than using the emulators onscreen
keyboard, but can alter the way your app works.
So, I definitely recommend testing your app on an emulator
that has this option un-ticked, so you get a feel of how it
behaves on the majority of devices.
Most users don't connect an external keyboard to
their phones, which is basically what this option is doing.
It's a big force to use the same keyboard as your users
can reveal some unexpected behaviour.
Now, it's much quicker to type on a computer keyboard
though, so I'm gonna leave this box ticked for now.
So, once you've got everything selected and set up,
click on finish, and the device manager sets everything up
and takes you back to the main AVG screen,
and you can now see our new device listed.
So at the right over here are three icons,
and we've already seen the little triangle down here
that actually gives you a list of options.
You can duplicate this AVD, you can wipe the data,
you can show where it is on disc, view the details,
or delete, or it can stop it if it's currently executing.
But for the other two icons,
the pencil icon will let you edit your emulator.
So, if I click on that,
and it just goes back to the screens
that we were working on previously,
and you can make changes to that emulator,
but obviously you don't need to do that
because we've just created it.
Now this green triangle here, well that actually starts
the emulator, so I'm gonna click that,
and the emulator will start up.
I'm just gonna move that over,
I'm just gonna close that little screen down now.
Now, it takes a little while for the emulator to start up,
even on my Mac with 32 gigabytes of RAM.
So, you may have to be patient depending on the speed
and capacity of your computer.
And it can take literally half an hour or longer
to start an emulator up on some systems,
so it's a good idea to start it before you
actually start coding.
That way it's up and going, and it's ready for you to use.
Now I'm gonna let Android Studio launch the emulator for us,
so I'm gonna close this one down for now.
But if your emulator takes a long time to start then launch
one from here so that it's available when you need it.
So I'm just gonna click on over here, click on close,
hold the button down, and select power off.
Now that's shut down the emulator, they send you a little
confirmation in the bottom right hand corner.
Now, the last thing I wanna point out is the three different
types of system images in terms of their behaviours.
Now the easiest place to see this is in the SDK manager.
So I'm gonna come over here,
tools, Android, SDK manager.
And we're gonna come down here and click on show package
details, make sure that's checked.
And that's obviously available in the
SDK platforms tab up here.
Now, starting with Android 8,
and ignoring the Android TV and Android Wear system images,
you can see that we've got various system images available.
Now, I don't know if Google is going to be releasing
a Redmi, which is for Oreo,
but, at the moment, I haven't got them available.
But I have got are two Intel x86 images available,
Googles APIs Intel x86 and Google Play Intel x86.
And again, we're ignoring the
Android TV Intel x86 Atom System Image.
So if you need route access to the AVD,
and we'll be seeing that later in this course,
then we'll have to use the Google APIs system image.
But if you need access to the Google Play Store
so that you can instal apps on the device,
then you'll want to use the Google Play system image.
There is a third variant,
and we can see in the Android 4.2 section,
all the way down here there's an Intel x86 system image
with neither Google APIs or Google Play APIs.
You can see here just Intel x86 Atom System Image.
In the YouTube section of this course I'm gonna be using
the API 17 version of this system image,
Android 4.2, and I'm only going to be using that to
show you an error we'll get because YouTube
isn't installed on this system image.
It's also a good version to check when we look at
material design in section nine.
Now, starting from the top again,
the system images we're gonna be using are the
two Android 8 Oreo ones.
The Google API Intel x86 Atom System Image,
and the Google Play Intel x86 Atom System Image,
that's from Android 8.
And under Android Nougat, we're also gonna be using
the Google APIs Intel x86 Atom.
And as I mentioned, right down to Android 4.2,
we're going to be using this one as well.
Now, if you're running Windows and can't get HAXM working,
then you won't be able to use the x86 system images
from Android Studio.
There is a way to run them from the command line,
and I'm gonna be putting a document in the
FAQ section describing how to do that.
And it'll also describe some other options
for you to consider as well.
So that's emulators, we've now got one installed.
Let's move onto the next video.
We're gonna actually get our Hello World app
running on this emulator.
So, I'll see you in the next video.