Tuesday, January 26, 2016

Android Studio- Running and Debugging an Emulator

So far, we have finished downloading Android Studio.  Even if you don't have an Android phone, Studio comes with an emulator, or a virtual phone that simulates your apps.  Open Studio and you should see this screen:

Click the top tab, "Start a new Android Studio Project."  You can pick any app name you like on the next screen.  Click next again to choose which version of Android you can program for.  Leave this as default and click next again.  You should see a screen of android phones.  Select the tab that says "blank activity" and click next. Leave the next screen values as default an finish!

Creating a new Studio project takes a couple of minutes to load, after which you will see a page like the following:

If you have a Windows computer, the phone in the center will be blank, and if you have a map, the phone will have a circle-shaped button at the bottom.

Near the top of your screen, you will see an icon of the Android robot with a blue down arrow in front of it.  (center icon in picture).

This is your SDK Manager.  Open the button to see the following screen:

 You will see several folders named "Android 5.1.1 (API 22)", "Android 5.0.1 (API 21)", etc.  Look at the drop down menu and make sure that at least 1 folder has the files installed that the above picture has (preferably the API 21 or API 22).  Once you are done, close the SDK Manager.

Now, at the top center of the screen, you'll see a green arrow button.  Click this button to run your app.  A screen will appear prompting you to choose a device.  Select "launch emulator" and click the "..." button at the right side of the popup.

A new popup will appear asking to create a virtual device (emulator).  At the bottom left of the screen, click "create virtual device".  A screen will appear like below:

 On the category pane, select phone.  On the main pane, select any phone device you like (preferably one of the top options.  Click Next, and you will see a page titled "system image".  Select an option with black colored text.  If none of them are colored black and ask for a download, download the release with API Level equal or less than to the API Level you downloaded in the SDK Manager.

Click next and then Finish to complete creating your emulator.  Now, try running your app and select the emulator you just built.  In a couple of minutes, a popup screen of a phone will appear and will display your app!

No comments:

Post a Comment