CS453 | mobile programming
  • outline
  • projects
  • syllabus
  • links

Android Emulator

The Android SDK includes a virtual mobile device emulator that runs on your computer. The emulator lets you prototype, develop, and test Android applications without using a physical device. The "look" of the emulator will change depending on the AVD (android Virtual Device) properties you have setup

Android Emulator (4.0)Android Emulator

 

 

Android AVD manager --- this is where you setup different AVDs that let you simulate different devices in your emulator!!!!!

  • To use the emulator, you first must create one or more AVD configurations.

  • In each configuration, you specify an Android platform to run in the emulator and the set of hardware options and emulator skin you want to use. Then, when you launch the emulator, you specify the AVD configuration that you want to load.

  • Regardless of IDE used, the AVD manager stores the information about the AVDs in the .android directory (e.g. C:\Users\YOUR_UserName\.android)

 

Android Studio: Tools -> Android->AVD Manager      

You will see current AVD configurations (if any) that you have created --- you can select one here and launch it to run with "START" button or you can "Edit" it and change the configuration!!!

Android Studio

 

 

Create a New AVD (android virtual device) configuration

** this is showing a good setup for Android SDK 4.4.2 device

  1. STEP 1: Hit "Create Virtual Device" button
  2. STEP 2: Select the Hardware you are targeting with your virutal device
  3. STEP 3: choose target SDK
  4. STEP 4: setup orientation, name, etc.
    • Name = something meaningful to you
    • Target = SDK you previously installed (see Android SDK Manager)
    • CPU/ABI = if choice it is presented here
    • SD = Memory card size, can purchase Android devices with different sized SD cards, funciton of manufacturer, but, you can varry size here
    • Snapshot    = this is for faster loading of this AVD, stores most recent snapshot of it running
    • Use Host GPU= This is another option to help speed, but in this case not the launch but, running. If OpenGL graphics commands will utilize computer's GPU rather than emulate a GPU
    • Skin = can choose resolution, and look (can install for different devices if supported by manufacturer). SEE developer.android for details --- for each Targer SDK there are some pre-installed Emulator supported screen sized and skinned emulators for different devices.
        • this is where you get different screen resolutions/densities (xhdpi, hdpi, mdpi, ldpi).
    • Hardware = you will see default options, but, you can add ...for example camera to device by using "New" button.
  5. Hit "Finish"

 

 

 

Step 1: Launch AVD and hit Create Virutal Device button

Step 2: hardware

 

STEP 3: SDK target selection

STEP 4: setup name, orientation, etc.

ADVANCED SETTINGS

 

 

 

 

Hardware options for AVD

see Android.com for latest up to date list (this CAN CHANGE)

YOU NEED to add HW options to emulator to enable testing/emulation of certain HW. Example you need to add GPS support to true if

Characteristic Description Property
Device ram size The amount of physical RAM on the device, in megabytes. Default value is "96". hw.ramSize
Touch-screen support Whether there is a touch screen or not on the device. Default value is "yes". hw.touchScreen
Trackball support Whether there is a trackball on the device. Default value is "yes". hw.trackBall
Keyboard support Whether the device has a QWERTY keyboard. Default value is "yes". hw.keyboard
DPad support Whether the device has DPad keys. Default value is "yes". hw.dPad
GSM modem support Whether there is a GSM modem in the device. Default value is "yes". hw.gsmModem
Camera support Whether the device has a camera. Default value is "no". hw.camera
Maximum horizontal camera pixels Default value is "640". hw.camera.maxHorizontalPixels
Maximum vertical camera pixels Default value is "480". hw.camera.maxVerticalPixels
GPS support Whether there is a GPS in the device. Default value is "yes". hw.gps
Battery support Whether the device can run on a battery. Default value is "yes". hw.battery
Accelerometer Whether there is an accelerometer in the device. Default value is "yes". hw.accelerometer
Audio recording support Whether the device can record audio. Default value is "yes". hw.audioInput
Audio playback support Whether the device can play audio. Default value is "yes". hw.audioOutput
SD Card support Whether the device supports insertion/removal of virtual SD Cards. Default value is "yes". hw.sdCard
Cache partition support Whether we use a /cache partition on the device. Default value is "yes". disk.cachePartition
Cache partition size Default value is "66MB". disk.cachePartition.size
Abstracted LCD density Sets the generalized density characteristic used by the AVD's screen. Default value is "160". hw.lcd.density
Trackball support Whether there is a trackball present.

you are using Google Maps and GPS location. Note for Maps built-in applciation and many Google APIs, you MUST HAVE YOUR AVD setup for Google API not jus the standard Android

 

How to specify that your project will run using a specific AVD

  1. The minimum SDK that you have under your project properties must not be greater than the AVD you select for running your program with

  2. GO to Run->Edit Configurations and it will pop up the following window

  3. Select the AVD you wish --under target device. I LIKE TO HAVE THE OPTON OF SHOW CHOOSER DIALOG ---so that when I hit run it asks me each time what device I want (of the list that would work for the SDK I compiled the app to)

     

 

Android Studio

  1. Run->Edit Configurations -> Select app you are wanted to edit it for
  2. Select if want chooser at run time or to specify USB device or specific AVD

 

 

 

 

Here I am have selected USB device and am being prompted to tell which one...

 

 

 

Problems with AVD creation

  • Sometimes you can have problems with creating an AVD that are not explainable or could be bugs or issues with resources available.

  • Example: when trying to make a Samsung Galaxy Android 4.2, API 17 AVD with the following specs when you run you the following error (SOLUTION --- as found on web here and many other peope had same problem reduce memory size to 512)

  • SOLUTION FOR A PROBLEM WITH AN AVD: search on web on error message and read, read, read and try solutions if they make sense.

    AVD with a problem

    avd with problem

    ERROR (partial --when try to run an application with this AVD

    Android Emulator tor] Failed to allocate memory: 8 [2013-01-15 13:43:02 - Emulator]

    [2013-01-15 13:43:02 - Emulator] This application has requested the Runtime to terminate it in an unusual way.

     

    Solution -- reduce memory to 512

cs453:mobile programming

  • home
  • outline
  • projects
  • syllabus
  • links