Running on the Android Emulator

Bryson Payne
A free video tutorial from Bryson Payne
Best-Selling Author & Professor w/students in 163 countries
4.5 instructor rating • 4 courses • 50,974 students

Learn more from the full course

Learn Java the Easy Way: Build Desktop & Android Mobile Apps

A Hands-On Introduction to Programming in Java on PC, Mac, Linux and Android Devices.

12:06:02 of on-demand video • Updated July 2017

  • Create fun, playable, interactive apps like the animated, multi-touch BubbleDraw app, a Secret Messages app, and a Guessing Game!
  • Code your own desktop and mobile apps in Java and Android.
  • Master concepts like variables, loops, functions, and object-oriented programming concepts in a fun way with Java!
English [Auto] If you followed all the steps successfully so far you're really going to want to see this application running on a real Android device. Well there are two ways that we can make that happen in this lesson. I'm going to show you how to set up an emulator so that we'll be able to run this app live right here on our computer. You can do this on a Mac PC Linux. You'll be able to run this anywhere you can run your androids to you from. So I'm going to do that first thing in the next lesson I'm going to show you how to run on an actual Android device. So let's do this one first because it'll be really handy to just run this in an emulator on the computer that we're working on. So the first thing we want to do is we'll come up to your run button and give this a try and you'll see that you just don't have any devices connected right now. It'll say launch an emulator or choose a running device when we use a USP cable to plug in our Android tablet or phone will be able to do that from this screen right here we'll be able to choose that device when it's connected by us be. We'll see how to do that in the next lesson. But right now I'd like to set up an emulator that will simulate an Android device right on my Mac or PC. So I don't have any options yet. I'm going to click the Android virtual device manager and you'll see my avi or Android virtual device manager pops up and it says create a virtual device we can create a tablet or phone emulator Google where Android ware or Google watch Android TV Android Auto if you're riding them and you go on the dashboard of a car. So we'll create a virtual device and just create whatever kind of device you have. I happen to have a Nexus 7 tablet and it's a really handy thing. So I'm going to choose the Nexus 7 under tablet here if you want to write an application for your watch. You can choose the Android Wear square round if you're developing for an Android TV so that you can play your guessing game on the big TV in your living room. Then you can do that as well or come to tablet. And for me I want to do the Nexus 7. Just a nice screen size for me. You may choose to do an Android phone if you get an Android phone choose something that's close to your screen size or your exact device name. If I happens to be in the list I like my Nexus 7 tablet so I'm going to click next and then you'll see I've got lots of options for downloading a system image because we're running an emulator on our computer. It will actually set up an environment a sandbox that runs just like the device just like the processor in our device for our tablet PC or other Android device. So I need to download a system image for that emulator and then we can choose the next 86 version. And when I go next with that I'm going to say makes a 7 x 86. This is an emulator that works well on our desktop computers. And I'll show a few more advanced settings. I'm going to enable keyboard input. That's a good one to have on there. And I'll make this about 10:24 1 gig of RAM and you may have to give this a couple of minutes to set up and then you can start it or X 86 version right here. When you run this the first time it'll have to go through a good bit of set up so it may take a few minutes pause this if you need to. And then we'll start back up when you see your running Android virtual device. All right. That took a few minutes to get our Android emulator up but now we have an android emulator working you might have a welcome screen or some other information you can just click through and clicks will work just like touches on a regular device we're emulating the device here. So we can click on a button and we can swipe through different options we can push up and we can push down. If you have to unlock the device and you just have to slide up click on the lock icon and push up if you need to unlock it depending on which version of which device you chose your emulator. Well now that we've got this running on a new emulator we can give our app a Ryne and you notice it says choose a running device now and we'll click OK when we come back to our device simulator and it takes just a few seconds to compile and push the out to the device each time we give that just a few seconds and you can see a little about put down here below so that you can see what's happening in the app. There we go Wow. Very cool. Now we have our app showing in the virtual device and it looks just like the version that we typed in on the screen. So let's try a number maybe 50 to get a second to catch my 50 there but I'm going to guess 50 was too high. Guess again. Let's try 25. That's too high. 12 was too high six is too low. I'm using my backspace on my normal keys because I chose to allow the keyboard to communicate nines to high. So let's try seven seven was the number we won and play again and we wrapped around just a little bit. So I might change my message there for the winning message but we can actually see this out working. So let's guess again 50 is too high. So there are a few finishing touches that we'd like to do to the lay out here so that it looks a little nicer but we actually have a running Android application. We can make changes and then just run. You don't even have to close this window you can just minimize this running window in the background. In fact I'll do that now. And as we come back and make changes to our application we can run it again and we'll see that new version push much faster. You only have a long startup time the very first time you run your Android emulator if you'll keep that open. Just maybe minimize it so that you can come back to it. It will refresh and load over every time you press the run button to build this and run the application again. When we come back in the next lesson I'm going to show you how to open up this running program on a real Android device will have a little bit of setup but then we'll be able to plug this in and run. We'll see in the next lesson.