1 00:00:00,050 --> 00:00:04,673 [SOUND] Hi, my name is Ben and welcome to 2 00:00:04,673 --> 00:00:10,170 getting started with the Android emulator. 3 00:00:10,170 --> 00:00:14,810 In this workshop, we're going to become experts at using the Android emulator. 4 00:00:15,810 --> 00:00:19,230 The first thing we'll need to do is set up a virtual device. 5 00:00:19,230 --> 00:00:22,570 A virtual device is set of hardware and software options 6 00:00:22,570 --> 00:00:27,000 which tells the Android emulator what sort of device we would like to emulate. 7 00:00:27,000 --> 00:00:29,410 If you've recently downloaded Android Studio, 8 00:00:29,410 --> 00:00:33,000 you may already have an appropriate virtual device created for you. 9 00:00:33,000 --> 00:00:36,720 However, you might still want to follow along to see how to create your own. 10 00:00:37,970 --> 00:00:39,820 Before we create our virtual device, 11 00:00:39,820 --> 00:00:42,500 we'll want to make sure that we have HAXM installed. 12 00:00:42,500 --> 00:00:45,490 HAXM is hardware acceleration for the emulator. 13 00:00:45,490 --> 00:00:48,980 With HAXM, the emulator runs much quicker than it used to. 14 00:00:48,980 --> 00:00:52,425 We can check if HAXM is installed by opening the Android SDK manager, 15 00:00:57,998 --> 00:01:03,870 clicking on the SDK Tools tab, and looking for a checkbox next to the HAXM entry. 16 00:01:06,700 --> 00:01:08,660 If HAXM isn't installed, go ahead and 17 00:01:08,660 --> 00:01:11,820 install it by checking the box on the left and then clicking apply. 18 00:01:13,510 --> 00:01:18,250 Once we verify that HAXM is installed we can go about creating our virtual device. 19 00:01:18,250 --> 00:01:19,140 We can create and 20 00:01:19,140 --> 00:01:23,090 manage our virtual devices in the Android Virtual Device Manager. 21 00:01:23,090 --> 00:01:25,060 Let's click on the AVD Manager to open it. 22 00:01:27,200 --> 00:01:30,418 Then, click on Create Virtual Device to begin the setup process. 23 00:01:33,374 --> 00:01:37,930 The first choice we need to make is what hardware we would like to use. 24 00:01:37,930 --> 00:01:40,970 We can pick from the list of default hardware profiles or 25 00:01:40,970 --> 00:01:42,730 we can create our own. 26 00:01:42,730 --> 00:01:45,280 Let's click on new hardware profile to get an idea 27 00:01:45,280 --> 00:01:46,510 of what we're really choosing here. 28 00:01:48,900 --> 00:01:52,350 It looks like it's just picking the hardware features of our virtual device, 29 00:01:52,350 --> 00:01:57,300 like what resolution it is, if it has a front facing camera, and 30 00:01:57,300 --> 00:01:59,340 what sensors does it have. 31 00:01:59,340 --> 00:02:02,340 This would be real useful if we wanted to emulate a device 32 00:02:02,340 --> 00:02:04,490 that wasn't on the previous list. 33 00:02:04,490 --> 00:02:09,460 However, for our purposes the Nexus 6 device definition will do just fine. 34 00:02:09,460 --> 00:02:12,160 So let's select the Nexus 6 and then click Next. 35 00:02:14,340 --> 00:02:16,930 Next we need to pick a system image for our device. 36 00:02:18,080 --> 00:02:21,760 The system image represents which version of Android we want to have 37 00:02:21,760 --> 00:02:22,839 on our virtual device. 38 00:02:23,940 --> 00:02:28,530 An important note is that we can only utilize HAXM on an x86 system image. 39 00:02:29,850 --> 00:02:34,050 x86 is the type of processor your computer normally uses, 40 00:02:34,050 --> 00:02:39,850 whereas ARM is typically used on mobile devices. 41 00:02:39,850 --> 00:02:42,310 Since we're running the emulator on a computer, 42 00:02:42,310 --> 00:02:46,020 It will be faster to use the x86 system image. 43 00:02:46,020 --> 00:02:47,620 Another thing to mention is the target. 44 00:02:48,930 --> 00:02:53,680 You may have noticed that some of the targets contain the phrase Google APIs. 45 00:02:53,680 --> 00:02:55,700 If we pick a target with Google APIs, 46 00:02:55,700 --> 00:03:01,280 our emulator will come preloaded with the Google APIs, such as Google maps. 47 00:03:01,280 --> 00:03:04,630 Let's pick a Marshmallow x86 system image and click Next. 48 00:03:06,825 --> 00:03:10,670 Lastly, we have several customization options for our virtual device. 49 00:03:10,670 --> 00:03:16,260 We can set its starting size and orientation along with whether or not 50 00:03:16,260 --> 00:03:20,910 it will show a frame around our virtual device to make it look like a real phone. 51 00:03:20,910 --> 00:03:24,890 If we click on Show Advanced Settings, another option that we have access to 52 00:03:24,890 --> 00:03:29,310 is setting the source for the cameras on our virtual device. 53 00:03:29,310 --> 00:03:32,510 We can choose to not have a camera and 54 00:03:32,510 --> 00:03:34,420 opening the camera will crash the camera app. 55 00:03:35,590 --> 00:03:40,000 We can have an emulated camera which will display a default image in our camera, 56 00:03:40,000 --> 00:03:43,440 or if your computer has a webcam you can choose for 57 00:03:43,440 --> 00:03:45,740 the webcam image to display as the camera image. 58 00:03:46,890 --> 00:03:48,505 I'm going to leave these both as emulated. 59 00:03:50,727 --> 00:03:54,149 Also, if you're making an app that relies on a network connection, 60 00:03:54,149 --> 00:03:58,054 you'll probably want to test how it works under various network conditions. 61 00:03:58,054 --> 00:04:02,540 We can set many different networks speeds, and 62 00:04:02,540 --> 00:04:07,596 latencies to make testing much more comprehensive. 63 00:04:07,596 --> 00:04:10,989 The last important thing to mention here is that we want to make sure that 64 00:04:10,989 --> 00:04:13,670 the Enable keyboard input box is checked. 65 00:04:13,670 --> 00:04:16,600 This lets us type with our physical keyboard instead of having to 66 00:04:16,600 --> 00:04:17,950 use the virtual device keyboard. 67 00:04:19,160 --> 00:04:23,550 Now we can hit Finish, And 68 00:04:23,550 --> 00:04:26,425 click the Play button next to our virtual device to test it out. 69 00:04:38,342 --> 00:04:39,712 Looks great. 70 00:04:39,712 --> 00:04:43,338 Let's quickly go into the camera app and see what the emulated camera looks like. 71 00:04:46,611 --> 00:04:47,923 Hey, that's kind of neat. 72 00:04:47,923 --> 00:04:48,925 Let's take a picture of it. 73 00:04:54,761 --> 00:04:59,517 Another way we can launch our virtual device is by choosing it in the run debug 74 00:04:59,517 --> 00:05:01,330 configurations. 75 00:05:01,330 --> 00:05:05,980 Let's click on our app and select edit configurations, and 76 00:05:05,980 --> 00:05:08,970 under target devices down here, 77 00:05:08,970 --> 00:05:13,720 let's select emulator and then pick our virtual device as the target device. 78 00:05:15,050 --> 00:05:19,050 Now when we run our app, it will start directly in the emulator. 79 00:05:19,050 --> 00:05:22,000 And if the emulator isn't running it will start automatically. 80 00:05:23,070 --> 00:05:23,570 Awesome.