SlideShare a Scribd company logo
Android Environment
Emulator
Victor Matos
Cleveland State University
Notes are based on:
http://developer.android.com/index.html
http://developer.android.com/guide/developing/tools/emulator.html
1
Part 2-b
2
Android Emulator
• The Android SDK includes a mobile device emulator -- a virtual mobile
device that runs on your computer.
• The emulator lets you prototype, develop, and test Android applications
without using a physical device.
• The Android emulator mimics all of the hardware and software features of
a typical mobile device, except that it can not receive or place actual
phone calls.
• It provides a variety of navigation and control keys, which you can "press"
using your mouse or keyboard to generate events for your application.
• It also provides a screen in which your application is displayed, together
with any other Android applications running.
2
3
Android Emulator v1.5 Skin
3
Hang up
Back
Volume
Power
Status Bar – Notification Line
Home
Call
Menu
Tab
Launch
Pad
4
Android Emulator v1.6 Skin
4
Hang up
Back
Volume
Status Bar – Notification Line
Home
Call
Menu
Tab
Launch
Pad
Power
5
Android Emulator v1.6 Skin
5
Hang up
Back
Volume
Status Bar – Notification Line
Home
Call
Menu
Tab
Launch
Pad
Power
6
Android Emulator
6
Keyboard OS function
Escape Back button
Home Home button
F2, PageUp Menu (Soft-Left) button
Shift-F2, PageDown Start (Soft-Right) button
F3 Call/Dial button
F4 Hangup / EndCall button
F5 Search button
F7 Power button
Ctrl-F3, Ctrl-KEYPAD_5 Camera button
Ctrl-F5, KEYPAD_PLUS Volume up button
Ctrl-F6, KEYPAD_MINUS Volume down button
KEYPAD_5 DPad center
KEYPAD_4 DPad left
KEYPAD_6 DPad right
KEYPAD_8 DPad up
KEYPAD_2 DPad down
F8 toggle cell network on/off
F9 toggle code profiling (when -trace option set)
Alt-ENTER toggle FullScreen mode
Ctrl-T toggle trackball mode
Ctrl-F11, KEYPAD_7 switch to previous layout
Ctrl-F12, KEYPAD_9 switch to next layout
Controlling the Android Emulator
through keyboard keys
Keypad keys only work when
NumLock is deactivated.
7
Android Emulator
7
Features - Emulating First Generation Android Phones
The Android emulator supports many hardware features likely to be found on mobile
devices (such as the HTC-G1), including:
1. An ARMv5 CPU and the corresponding memory-management unit (MMU)
2. A 16-bit LCD display (mimicking 360 x 480 pixels)
3. One or more keyboards (a Qwerty-based keyboard and associated
Dpad/Phone buttons)
4. A sound chip with output and input capabilities
5. Flash memory partitions (emulated through disk image files on the
development machine)
6. A GSM modem, including a simulated SIM Card
8
Android Emulator
8
Nexus One (newer Google developer phone)
Some phones in the
market already
surpass these specs
(Fall 2010)
9
Android Emulator
9
Working with Emulator Disk Images
The emulator uses mountable disk images (ANDROID SYSTEM IMAGE) stored on your
development machine to simulate flash (or similar) partitions on an actual device.
For example, it uses disk images containing
(1) an emulator-specific kernel,
(2) the Android system,
(3) a ram-disk image, and
(4) writeable images for user data and
simulated SD card.
By default, the Emulator always looks for the
disk images in the private storage area of the
AVD in use (c:android-sdk-windowsplatform … ) .
1010
Android Emulator
10
Working with Emulator Disk Images
If no platform images exist there
when the Emulator is launched,
it creates the images in the
AVD directory based on
default versions stored in the SDK.
Note:
The default storage location for AVDs is in
~/.android/avd on OS X and Linux,
C:Documents and Settings<user>.androidavd... on Windows XP, and
C:Users<user>.android on Windows Vista.
11
C:Documents and
SettingsAdministrator.androidavdAVD22GoogleAPI8.a
vd>a
Available Android targets:
id: 1 or "android-3"
Name: Android 1.5
Type: Platform
API level: 3
Revision: 4
Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L,
QVGA-P
id: 2 or "Google Inc.:Google APIs:3"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 3
Description: Android + Google APIs
Based on Android 1.5 (API level 3)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: QVGA-P, HVGA-L, HVGA (default), QVGA-L,
HVGA-P
id: 3 or "android-4"
Name: Android 1.6
Type: Platform
API level: 4
Revision: 3
Skins: HVGA (default), QVGA, WVGA800, WVGA854
id: 4 or "Google Inc.:Google APIs:4"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 1.6 (API level 4)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, HVGA (default), WVGA800, QVGA
id: 5 or "android-7"
Name: Android 2.1-update1
Type: Platform
API level: 7
Revision: 2
Skins: HVGA (default), QVGA, WQVGA400, WQVGA432,
WVGA800, WVGA854
id: 6 or "Google Inc.:Google APIs:7"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 2.1-update1 (API level 7)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, WQVGA400, HVGA (default),
WQVGA432, WVGA800, QVGA
id: 7 or "android-8"
Name: Android 2.2
Type: Platform
API level: 8
Revision: 2
Skins: HVGA (default), QVGA, WQVGA400, WQVGA432,
WVGA800, WVGA854
id: 8 or "Google Inc.:Google APIs:8"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 2
Description: Android + Google APIs
Based on Android 2.2 (API level 8)
Libraries:
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: WVGA854, WQVGA400, HVGA (default),
WQVGA432, WVGA800, QVGA
11
Android Emulator
11
Creating an AVD using the
android tool
Listing targets
To generate a list of system
image targets, use this
command:
android list targets
12
Android Emulator
12
Starting – Stopping the Emulator
To start an instance of the emulator from the command line, change to the tools/
folder of the SDK. Enter emulator command like this:
emulator -avd <avd_name>
This initializes the emulator and loads an AVD configuration .
After a few seconds you will see the emulator window appear on your screen.
If you are working in Eclipse, the ADT plugin for Eclipse installs your application and
starts the emulator automatically, when you run or debug the application.
To stop an emulator instance, just close the emulator's window.
To list all available AVDs enter DOS command
android list avd
13
Android Emulator
13
AVD - Android Virtual Devices
Android Virtual Devices (AVDs) are configurations of emulator options that let you
better model an actual device.
Each AVD is made up of:
• A hardware profile. You can set options to define the hardware features of the virtual
device. For example, you can define whether the device has a camera, whether it uses a
physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.
• A mapping to a system image. You can define what version of the Android platform will
run on the virtual device. You can choose a version of the standard Android platform or
the system image packaged with an SDK add-on.
• Other options. You can specify the emulator skin you want to use with the AVD, which
lets you control the screen dimensions, appearance, and so on. You can also specify the
emulated SD card to use with the AVD.
• A dedicated storage area on your development machine, in which is stored the device's
user data (installed applications, settings, and so on) and emulated SD card.
14
Android Emulator
14
AVD - Android Virtual Devices
You can create as many AVDs as you need, based on the types of
devices you want to model and the Android platforms and external
libraries you want to run your application on.
15
Android Emulator
15
Creating an AVD using the Eclipse-ADT Tool
From Eclipse, follow the sequence: Main menu (AVD Manager )
> Virtual Devices > New >
Provide a Name,
choose an Android target,
create a new SD card with about 2Gb,
choose a screen type,
add hardware devices…
Click on: Create AVD
(wait, it takes several minutes
to format the new SD card)
16
Android Emulator
16
Creating an AVD using the android tool
When creating an AVD, you simply specify the -c option, like this:
android create avd -n <avd_name> -t <targetID> -c <size>[K|M]
The –t (target) argument sets up a mapping between the AVD and the system
image that you want to use whenever the AVD is invoked. Later, when
applications use the AVD, they'll be running on the system that you specify in
the -t argument.
To specify the system image to use, you refer to its target ID — an integer — as
assigned by the android tool. The target ID is not derived from the system
image name, version, or API Level, or other attribute, so you need to have the
android tool list the available system images and the target ID of each, as
described in the next section. You should do this before you run the android
create avd command.
17
Android Emulator
17
Example: Creating an AVD using the android tool
After listing all targets (see previous image) we have decided to make a
profile based on target id:4 to support SDK1.6 with Google API Mapping
libraries. It should also include a 1Gig SD card. We enter the command
android create avd -n myAVD4SD1G -t 4 -c 1024M
18
Android Emulator
18
Example: Creating an AVD using the android tool
Verifying what AVDs are available in the system:
19
Android Emulator
19
SD Card Emulation
• You can create a disk image and then load it to the emulator at startup, to
simulate the presence of a user's SD card in the device.
• The emulator supports emulated SDHC cards, so you can create an SD card image
of any size up to 128 gigabytes.
• You can browse, send files to, and copy/remove files from a simulated SD card
either with adb or the emulator.
Creating an SD card image using mksdcard
Use the mksdcard tool, included in the SDK, to create a FAT32 disk images.
mksdcard <size> <file>
For example:
mksdcard 1024M c:/temp/mysdcard.iso
20
Android Emulator
20
Android Emulator – How to use the SDCARD device
The general syntax to create an SD card is
mksdcard [ -l label ] <size> <file>
• The tool mksdcard is part of the Android SDK. The SD label is optional.
• The device’s size is expressed as an integer number followed by either K
(kilobytes) or M (megabytes).
Example: Create a 1GB SDcard device using the following command
mksdcard 1024M c:mysdcard.img
Run the emulator with the command
emulator -sdcard c:mysdcard.img
or alternatively
emulator -avd myAvdFile
21
Android Emulator
21
Moving Data, Music and Pictures to the Sdcard
1. Use the program ddms to push files into the SDcard (the emulator must be
running with the SD card attached to it).
2. Click on: Device > File Explorer, this will open a new window and there you will
select the SDcard.
3. Now you move data to the sdcard. Your options are
• Open a Windows Explore panel to drag & drop files/folders on the card, or
• Press on the button "Push File onto Device"
(see upper left icons: push, pull, delete).
( DDMS stands for Dalvik Debug Monitor Services. The program is located in the /tools folder of the SDK. Also available
in Eclipse perspective – Top upper right icons)
22
Android Emulator
22
Moving Data, Music and Pictures to the SDcard
23
Android Emulator
23
Moving Data, Music and Pictures to the SDcard
4. Return to the emulator. This time you will see the selected (music) files in the
SDcard
24
Android Emulator
24
Moving Data, Music and Pictures to the SDcard
5. Pictures appear by clicking the Application Pad and invoking the Gallery
application
25
Android Emulator
25
Android – Login into the OS shell
You can log into the OS Linux version of Android executing in the emulator and issue
selected commands.
1. Run the Android
emulator
2. Run adb application
as follows:
c:> adb shell
(adb is the Android
Debug Bridge app. It is
Located in the /tools
folder of the SDK)
26
Android Emulator
26
Android – Login into the OS shell
If more than one emulator is running (or your phone is
physically connected to the computer using the
USB cable) you need to identify the target.
Follow the steps:
1. Get a list of all active emulators
adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
HT845GZ45737 device
2. Run adb application as follows:
adb -s emulator-5554 shell
(adb is the Android Debug Bridge app. It is Located in the /tools folder of the SDK)
27
Android Emulator
27
NOTE1: Emulators & Hardware Devices
You may test your applications in either a software emulator or a hardware device.
All you need to do is connect your phone to the computer via USB cable.
On a command shell type the command: “adb devices“ you should see
something like “HT845GZ45737 device” indicating the presence of
your hardware device.
Gaining Root Access to Your Hardware device
A developer’s phone such as the G1 comes with root access enabled and is fully
opened.
Run the terminal application ( adb shell ) and see if you have the # prompt; if not try
the command su. It should give you the root prompt, if you have a permission denied
error then you do not have root access.
28
Android Emulator
28
NOTE2: Moving an app from (Rooted) Hardware to Emulator
If you want to transfer an app installed in your developer’s phone to the emulator,
follow the next steps:
1. Run command shell: > adb devices (find out the id of your hardware, say
HT845GZ45737 )
2. Pull the file from the device to your computer’s file system. Enter the command
adb -s HT845GZ45737 pull data/app/theInstalled.apk c:/theInstalled.apk
3. Disconnect your Android phone
4. Run an instance of the Emulator
5. Now install the app on the emulator using the command
adb -s emulator-5554 install c:theInstalledApp.apk
adb -s emulator-5554 uninstall data/app/theInstalled.apk
You should see a message indicating the size of the installed package, and Success.
29
Android Emulator
29
Android – Login into the OS shell
3. Android accepts a number of Linux shell commands including the useful set below
ls ................. show directory (alphabetical order)
mkdir .............. make a directory
rmdir .............. remove directory
rm -r .............. to delete folders with files
rm ................. remove files
mv ................. moving and renaming files
cat ................ displaying short files
cd ................. change current directory
pwd ................ find out what directory you are in
df ................. shows available disk space
chmod .............. changes permissions on a file
date ............... display date
exit ............... terminate session
30
Android Emulator
30
Android – Login into the OS shell
4. There is no copy (cp) command in Android, but you could use the cat instead.
For instance:
# cat data/app/theInstalledApp.apk > cache/theInstalledApp.apk
31
Android Emulator
31
Using the Emulator with “inserted” SD card from Eclipse
Additional Emulator Command Line Options:
-sdcard c:Android_Emulator_Datamysdcard.img -datadir c:Android_Emulator_Data
From Eclipse’s menu create
new launch configuration:
Run >
Run Configurations >
New icon
On the Target panel
1. Select existing Android
Virtual device (AVD)
2. Enter additional
Command Line Options
(see caption)
3. Apply > Run
32
Android Emulator
32
Sending Text Messages to the Emulator
1. Start the emulator.
2. Open a new shell and type :
c:> adb devices
so you know the emulator’s numeric port id (usually 5554, 5556, and so
on)
3. Connect to the console using telnet command like:
c:> telnet localhost 5554
4. After receiving the telnet prompt you can send a text message with the
command (no quotes needed for the message)
sms send <Sender’s phone number> <text message>
33
Android Emulator
33
Example:
Sending Text Messages
to the Emulator
34
Android Emulator
34
Making a Voice Call to the Emulator
1. Start the emulator.
2. Open a new shell and type :
adb devices
to know the emulator’s numeric port id (usually 5554, 5556, and so on)
3. Connect to the console using telnet command like:
telnet localhost 5554 (this is the ‘number’ to be called)
4. After receiving the telnet prompt you can place a call (voice) with the
command
gsm call <caller’s phone number>
35
Android Emulator
35
Example: Making a Phone
Call to the Emulator
36
Android Emulator
Using Eclipse’s DDMS facility
36
Emulator Control
With these controls, you can simulate special device states and activities. Features
include:
1. Telephony Status - change the state of the phone's Voice and Data plans (home,
roaming, searching, etc.), and simulate different kinds of network Speed and
Latency (GPRS, EDGE, UTMS, etc.).
2. Telephony Actions - perform simulated phone calls and SMS messages to the
emulator.
3. Location Controls - send mock location data to the emulator so that you can
perform location-aware operations like GPS mapping. To use the Location
Controls, launch your application in the Android emulator and open DDMS. Click
the Emulator Controls tab and scroll down to Location Controls. From here, you
can:
• Manually send individual longitude/latitude coordinates to the device. Click
Manual, select the coordinate format, fill in the fields and click Send.
• Use a GPX file describing a route for playback to the device.
37
Android Emulator
37
Using Eclipse to test Emulator’s Telephony Actions
38
Android Emulator
38
Questions ?
39
Android Emulator
39
Appendix 1 – Connecting your Hardware Device to the Computer
1. Use a mini-USB cable to link the device and your computer
2. Expand the Notification bar
3. Mount the device
You could now use the Eclipse-ADT-File Explorer panel to pull/push files to the
device.
40
Android Emulator
40
Appendix 1 – Emulator to Emulator Communication
1. Run two instances of the emulator (typical IDs are: 5554, 5556, … )
2. Dial (or send SMS) from one of them (say 5554) to the other (5556)
3. Press the Green/Red call buttons to accept/terminate the call
4. Try sending SMS (use numbers 5554 and 5556)

More Related Content

What's hot (20)

PPTX
Creating the first app with android studio
Parinita03
 
PPTX
Introduction to android
zeelpatel0504
 
PPTX
Android studio ppt
Swapanpreet Kaur
 
PDF
Android resource
Krazy Koder
 
PPTX
Android Services
Ahsanul Karim
 
PPT
Introduction to Google App Engine
rajdeep
 
PPTX
Tk2323 lecture 1 introduction to mobile application
MengChun Lam
 
PPT
Chapter03 Creating And Managing User Accounts
Raja Waseem Akhtar
 
PPT
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
PDF
Introduction to Mobile Application Development
Tharindu Dassanayake
 
PDF
Android Basic Components
Jussi Pohjolainen
 
PPTX
Android application development ppt
Gautam Kumar
 
PDF
Course 102: Lecture 14: Users and Permissions
Ahmed El-Arabawy
 
PDF
Windows Server 2019 -InspireTech 2019
Diana Carolina Torres Viasus
 
PPT
7) packaging and deployment
techbed
 
PPTX
Mobile operating system..
Aashish Uppal
 
PDF
Android ui dialog
Krazy Koder
 
PDF
Android datastorage
Krazy Koder
 
PPTX
Android studio installation
Faysal Hossain Shezan
 
PPT
Eclipse introduction IDE PRESENTATION
AYESHA JAVED
 
Creating the first app with android studio
Parinita03
 
Introduction to android
zeelpatel0504
 
Android studio ppt
Swapanpreet Kaur
 
Android resource
Krazy Koder
 
Android Services
Ahsanul Karim
 
Introduction to Google App Engine
rajdeep
 
Tk2323 lecture 1 introduction to mobile application
MengChun Lam
 
Chapter03 Creating And Managing User Accounts
Raja Waseem Akhtar
 
Shell and its types in LINUX
SHUBHA CHATURVEDI
 
Introduction to Mobile Application Development
Tharindu Dassanayake
 
Android Basic Components
Jussi Pohjolainen
 
Android application development ppt
Gautam Kumar
 
Course 102: Lecture 14: Users and Permissions
Ahmed El-Arabawy
 
Windows Server 2019 -InspireTech 2019
Diana Carolina Torres Viasus
 
7) packaging and deployment
techbed
 
Mobile operating system..
Aashish Uppal
 
Android ui dialog
Krazy Koder
 
Android datastorage
Krazy Koder
 
Android studio installation
Faysal Hossain Shezan
 
Eclipse introduction IDE PRESENTATION
AYESHA JAVED
 

Viewers also liked (20)

PPSX
La contabilidad
stellacaccioppoli
 
DOCX
Document 1 Long Document
sharrison2010
 
PDF
04 android
guru472
 
PPT
JDK1.6
india_mani
 
PPTX
How to configure monkey talk android agent
Dasun Eranthika
 
PDF
Use Combinatorial Testing for Mobile Device Fragmentation
Josiah Renaudin
 
PDF
Mobile Browser Internal (Blink Rendering Engine)
Hyungwook Lee
 
PDF
Study on Android Emulator
Samael Wang
 
PPTX
How Browser Works?
Vova Voyevidka
 
PDF
Mobile First: How To Approach Mobile Testing!
Usersnap
 
PPTX
Evolution of web browsers ppt
Jyothi Reddy
 
PDF
Architecture of the Web browser
Sabin Buraga
 
PPTX
Web browser architecture
Nguyen Quang
 
PPT
Web browser
Hardik Kakadiya
 
PPTX
Presentation on iOS
Harry Lovylife
 
PPT
Introduction to Simulation
chimco.net
 
PPT
Web Browsers
Neha Sharma
 
PPTX
Web Browsers
Aahmed Hussain
 
PPTX
Android ppt
Pooja Garg
 
La contabilidad
stellacaccioppoli
 
Document 1 Long Document
sharrison2010
 
04 android
guru472
 
JDK1.6
india_mani
 
How to configure monkey talk android agent
Dasun Eranthika
 
Use Combinatorial Testing for Mobile Device Fragmentation
Josiah Renaudin
 
Mobile Browser Internal (Blink Rendering Engine)
Hyungwook Lee
 
Study on Android Emulator
Samael Wang
 
How Browser Works?
Vova Voyevidka
 
Mobile First: How To Approach Mobile Testing!
Usersnap
 
Evolution of web browsers ppt
Jyothi Reddy
 
Architecture of the Web browser
Sabin Buraga
 
Web browser architecture
Nguyen Quang
 
Web browser
Hardik Kakadiya
 
Presentation on iOS
Harry Lovylife
 
Introduction to Simulation
chimco.net
 
Web Browsers
Neha Sharma
 
Web Browsers
Aahmed Hussain
 
Android ppt
Pooja Garg
 
Ad

Similar to Android chapter02-setup2-emulator (20)

PPTX
Android chapter02-setup2-emulator
Tran Le Hoan
 
PDF
Android Overview
Jussi Pohjolainen
 
PPTX
Android tools for testers
Maksim Kovalev
 
PPTX
How to create android applications
TOPS Technologies
 
PDF
3 getting to know the android tools - en-us
Juarez Junior
 
PPT
Android studio history, emulator, Building blocks
BarkaviP2
 
PPTX
Mobile Applicaiton Development Unit 2.pptx
nihitagrawal4
 
PPTX
Android Development Tools Overview
Mike Wolfson
 
PPTX
Android
BVP GTUG
 
PPT
Getting started with android dev and test perspective
Gunjan Kumar
 
PPTX
Notes Unit2.pptx
MIT Autonomous Aurangabad
 
PPTX
03 Beginning Android Application Development
Arief Gunawan
 
PPTX
this is PPT for mobail application development
swapnildhage339
 
PDF
Mobile operating systems - Application Benchmarking
Nicolas Demetriou
 
PPTX
Overview of Adroid Architecture.pptx
debasish duarah
 
PPTX
Android App development I
Thenraja Vettivelraj
 
PPT
Introduction to android sessions new
Joe Jacob
 
PPT
Lec004 setting up for development
Eyad Almasri
 
PPTX
Introduction_to_android_and_android_studio
Abdul Basit
 
Android chapter02-setup2-emulator
Tran Le Hoan
 
Android Overview
Jussi Pohjolainen
 
Android tools for testers
Maksim Kovalev
 
How to create android applications
TOPS Technologies
 
3 getting to know the android tools - en-us
Juarez Junior
 
Android studio history, emulator, Building blocks
BarkaviP2
 
Mobile Applicaiton Development Unit 2.pptx
nihitagrawal4
 
Android Development Tools Overview
Mike Wolfson
 
Android
BVP GTUG
 
Getting started with android dev and test perspective
Gunjan Kumar
 
Notes Unit2.pptx
MIT Autonomous Aurangabad
 
03 Beginning Android Application Development
Arief Gunawan
 
this is PPT for mobail application development
swapnildhage339
 
Mobile operating systems - Application Benchmarking
Nicolas Demetriou
 
Overview of Adroid Architecture.pptx
debasish duarah
 
Android App development I
Thenraja Vettivelraj
 
Introduction to android sessions new
Joe Jacob
 
Lec004 setting up for development
Eyad Almasri
 
Introduction_to_android_and_android_studio
Abdul Basit
 
Ad

Recently uploaded (20)

PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 

Android chapter02-setup2-emulator

  • 1. Android Environment Emulator Victor Matos Cleveland State University Notes are based on: http://developer.android.com/index.html http://developer.android.com/guide/developing/tools/emulator.html 1 Part 2-b
  • 2. 2 Android Emulator • The Android SDK includes a mobile device emulator -- a virtual mobile device that runs on your computer. • The emulator lets you prototype, develop, and test Android applications without using a physical device. • The Android emulator mimics all of the hardware and software features of a typical mobile device, except that it can not receive or place actual phone calls. • It provides a variety of navigation and control keys, which you can "press" using your mouse or keyboard to generate events for your application. • It also provides a screen in which your application is displayed, together with any other Android applications running. 2
  • 3. 3 Android Emulator v1.5 Skin 3 Hang up Back Volume Power Status Bar – Notification Line Home Call Menu Tab Launch Pad
  • 4. 4 Android Emulator v1.6 Skin 4 Hang up Back Volume Status Bar – Notification Line Home Call Menu Tab Launch Pad Power
  • 5. 5 Android Emulator v1.6 Skin 5 Hang up Back Volume Status Bar – Notification Line Home Call Menu Tab Launch Pad Power
  • 6. 6 Android Emulator 6 Keyboard OS function Escape Back button Home Home button F2, PageUp Menu (Soft-Left) button Shift-F2, PageDown Start (Soft-Right) button F3 Call/Dial button F4 Hangup / EndCall button F5 Search button F7 Power button Ctrl-F3, Ctrl-KEYPAD_5 Camera button Ctrl-F5, KEYPAD_PLUS Volume up button Ctrl-F6, KEYPAD_MINUS Volume down button KEYPAD_5 DPad center KEYPAD_4 DPad left KEYPAD_6 DPad right KEYPAD_8 DPad up KEYPAD_2 DPad down F8 toggle cell network on/off F9 toggle code profiling (when -trace option set) Alt-ENTER toggle FullScreen mode Ctrl-T toggle trackball mode Ctrl-F11, KEYPAD_7 switch to previous layout Ctrl-F12, KEYPAD_9 switch to next layout Controlling the Android Emulator through keyboard keys Keypad keys only work when NumLock is deactivated.
  • 7. 7 Android Emulator 7 Features - Emulating First Generation Android Phones The Android emulator supports many hardware features likely to be found on mobile devices (such as the HTC-G1), including: 1. An ARMv5 CPU and the corresponding memory-management unit (MMU) 2. A 16-bit LCD display (mimicking 360 x 480 pixels) 3. One or more keyboards (a Qwerty-based keyboard and associated Dpad/Phone buttons) 4. A sound chip with output and input capabilities 5. Flash memory partitions (emulated through disk image files on the development machine) 6. A GSM modem, including a simulated SIM Card
  • 8. 8 Android Emulator 8 Nexus One (newer Google developer phone) Some phones in the market already surpass these specs (Fall 2010)
  • 9. 9 Android Emulator 9 Working with Emulator Disk Images The emulator uses mountable disk images (ANDROID SYSTEM IMAGE) stored on your development machine to simulate flash (or similar) partitions on an actual device. For example, it uses disk images containing (1) an emulator-specific kernel, (2) the Android system, (3) a ram-disk image, and (4) writeable images for user data and simulated SD card. By default, the Emulator always looks for the disk images in the private storage area of the AVD in use (c:android-sdk-windowsplatform … ) .
  • 10. 1010 Android Emulator 10 Working with Emulator Disk Images If no platform images exist there when the Emulator is launched, it creates the images in the AVD directory based on default versions stored in the SDK. Note: The default storage location for AVDs is in ~/.android/avd on OS X and Linux, C:Documents and Settings<user>.androidavd... on Windows XP, and C:Users<user>.android on Windows Vista.
  • 11. 11 C:Documents and SettingsAdministrator.androidavdAVD22GoogleAPI8.a vd>a Available Android targets: id: 1 or "android-3" Name: Android 1.5 Type: Platform API level: 3 Revision: 4 Skins: HVGA (default), HVGA-L, HVGA-P, QVGA-L, QVGA-P id: 2 or "Google Inc.:Google APIs:3" Name: Google APIs Type: Add-On Vendor: Google Inc. Revision: 3 Description: Android + Google APIs Based on Android 1.5 (API level 3) Libraries: * com.google.android.maps (maps.jar) API for Google Maps Skins: QVGA-P, HVGA-L, HVGA (default), QVGA-L, HVGA-P id: 3 or "android-4" Name: Android 1.6 Type: Platform API level: 4 Revision: 3 Skins: HVGA (default), QVGA, WVGA800, WVGA854 id: 4 or "Google Inc.:Google APIs:4" Name: Google APIs Type: Add-On Vendor: Google Inc. Revision: 2 Description: Android + Google APIs Based on Android 1.6 (API level 4) Libraries: * com.google.android.maps (maps.jar) API for Google Maps Skins: WVGA854, HVGA (default), WVGA800, QVGA id: 5 or "android-7" Name: Android 2.1-update1 Type: Platform API level: 7 Revision: 2 Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854 id: 6 or "Google Inc.:Google APIs:7" Name: Google APIs Type: Add-On Vendor: Google Inc. Revision: 1 Description: Android + Google APIs Based on Android 2.1-update1 (API level 7) Libraries: * com.google.android.maps (maps.jar) API for Google Maps Skins: WVGA854, WQVGA400, HVGA (default), WQVGA432, WVGA800, QVGA id: 7 or "android-8" Name: Android 2.2 Type: Platform API level: 8 Revision: 2 Skins: HVGA (default), QVGA, WQVGA400, WQVGA432, WVGA800, WVGA854 id: 8 or "Google Inc.:Google APIs:8" Name: Google APIs Type: Add-On Vendor: Google Inc. Revision: 2 Description: Android + Google APIs Based on Android 2.2 (API level 8) Libraries: * com.google.android.maps (maps.jar) API for Google Maps Skins: WVGA854, WQVGA400, HVGA (default), WQVGA432, WVGA800, QVGA 11 Android Emulator 11 Creating an AVD using the android tool Listing targets To generate a list of system image targets, use this command: android list targets
  • 12. 12 Android Emulator 12 Starting – Stopping the Emulator To start an instance of the emulator from the command line, change to the tools/ folder of the SDK. Enter emulator command like this: emulator -avd <avd_name> This initializes the emulator and loads an AVD configuration . After a few seconds you will see the emulator window appear on your screen. If you are working in Eclipse, the ADT plugin for Eclipse installs your application and starts the emulator automatically, when you run or debug the application. To stop an emulator instance, just close the emulator's window. To list all available AVDs enter DOS command android list avd
  • 13. 13 Android Emulator 13 AVD - Android Virtual Devices Android Virtual Devices (AVDs) are configurations of emulator options that let you better model an actual device. Each AVD is made up of: • A hardware profile. You can set options to define the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on. • A mapping to a system image. You can define what version of the Android platform will run on the virtual device. You can choose a version of the standard Android platform or the system image packaged with an SDK add-on. • Other options. You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance, and so on. You can also specify the emulated SD card to use with the AVD. • A dedicated storage area on your development machine, in which is stored the device's user data (installed applications, settings, and so on) and emulated SD card.
  • 14. 14 Android Emulator 14 AVD - Android Virtual Devices You can create as many AVDs as you need, based on the types of devices you want to model and the Android platforms and external libraries you want to run your application on.
  • 15. 15 Android Emulator 15 Creating an AVD using the Eclipse-ADT Tool From Eclipse, follow the sequence: Main menu (AVD Manager ) > Virtual Devices > New > Provide a Name, choose an Android target, create a new SD card with about 2Gb, choose a screen type, add hardware devices… Click on: Create AVD (wait, it takes several minutes to format the new SD card)
  • 16. 16 Android Emulator 16 Creating an AVD using the android tool When creating an AVD, you simply specify the -c option, like this: android create avd -n <avd_name> -t <targetID> -c <size>[K|M] The –t (target) argument sets up a mapping between the AVD and the system image that you want to use whenever the AVD is invoked. Later, when applications use the AVD, they'll be running on the system that you specify in the -t argument. To specify the system image to use, you refer to its target ID — an integer — as assigned by the android tool. The target ID is not derived from the system image name, version, or API Level, or other attribute, so you need to have the android tool list the available system images and the target ID of each, as described in the next section. You should do this before you run the android create avd command.
  • 17. 17 Android Emulator 17 Example: Creating an AVD using the android tool After listing all targets (see previous image) we have decided to make a profile based on target id:4 to support SDK1.6 with Google API Mapping libraries. It should also include a 1Gig SD card. We enter the command android create avd -n myAVD4SD1G -t 4 -c 1024M
  • 18. 18 Android Emulator 18 Example: Creating an AVD using the android tool Verifying what AVDs are available in the system:
  • 19. 19 Android Emulator 19 SD Card Emulation • You can create a disk image and then load it to the emulator at startup, to simulate the presence of a user's SD card in the device. • The emulator supports emulated SDHC cards, so you can create an SD card image of any size up to 128 gigabytes. • You can browse, send files to, and copy/remove files from a simulated SD card either with adb or the emulator. Creating an SD card image using mksdcard Use the mksdcard tool, included in the SDK, to create a FAT32 disk images. mksdcard <size> <file> For example: mksdcard 1024M c:/temp/mysdcard.iso
  • 20. 20 Android Emulator 20 Android Emulator – How to use the SDCARD device The general syntax to create an SD card is mksdcard [ -l label ] <size> <file> • The tool mksdcard is part of the Android SDK. The SD label is optional. • The device’s size is expressed as an integer number followed by either K (kilobytes) or M (megabytes). Example: Create a 1GB SDcard device using the following command mksdcard 1024M c:mysdcard.img Run the emulator with the command emulator -sdcard c:mysdcard.img or alternatively emulator -avd myAvdFile
  • 21. 21 Android Emulator 21 Moving Data, Music and Pictures to the Sdcard 1. Use the program ddms to push files into the SDcard (the emulator must be running with the SD card attached to it). 2. Click on: Device > File Explorer, this will open a new window and there you will select the SDcard. 3. Now you move data to the sdcard. Your options are • Open a Windows Explore panel to drag & drop files/folders on the card, or • Press on the button "Push File onto Device" (see upper left icons: push, pull, delete). ( DDMS stands for Dalvik Debug Monitor Services. The program is located in the /tools folder of the SDK. Also available in Eclipse perspective – Top upper right icons)
  • 22. 22 Android Emulator 22 Moving Data, Music and Pictures to the SDcard
  • 23. 23 Android Emulator 23 Moving Data, Music and Pictures to the SDcard 4. Return to the emulator. This time you will see the selected (music) files in the SDcard
  • 24. 24 Android Emulator 24 Moving Data, Music and Pictures to the SDcard 5. Pictures appear by clicking the Application Pad and invoking the Gallery application
  • 25. 25 Android Emulator 25 Android – Login into the OS shell You can log into the OS Linux version of Android executing in the emulator and issue selected commands. 1. Run the Android emulator 2. Run adb application as follows: c:> adb shell (adb is the Android Debug Bridge app. It is Located in the /tools folder of the SDK)
  • 26. 26 Android Emulator 26 Android – Login into the OS shell If more than one emulator is running (or your phone is physically connected to the computer using the USB cable) you need to identify the target. Follow the steps: 1. Get a list of all active emulators adb devices List of devices attached emulator-5554 device emulator-5556 device HT845GZ45737 device 2. Run adb application as follows: adb -s emulator-5554 shell (adb is the Android Debug Bridge app. It is Located in the /tools folder of the SDK)
  • 27. 27 Android Emulator 27 NOTE1: Emulators & Hardware Devices You may test your applications in either a software emulator or a hardware device. All you need to do is connect your phone to the computer via USB cable. On a command shell type the command: “adb devices“ you should see something like “HT845GZ45737 device” indicating the presence of your hardware device. Gaining Root Access to Your Hardware device A developer’s phone such as the G1 comes with root access enabled and is fully opened. Run the terminal application ( adb shell ) and see if you have the # prompt; if not try the command su. It should give you the root prompt, if you have a permission denied error then you do not have root access.
  • 28. 28 Android Emulator 28 NOTE2: Moving an app from (Rooted) Hardware to Emulator If you want to transfer an app installed in your developer’s phone to the emulator, follow the next steps: 1. Run command shell: > adb devices (find out the id of your hardware, say HT845GZ45737 ) 2. Pull the file from the device to your computer’s file system. Enter the command adb -s HT845GZ45737 pull data/app/theInstalled.apk c:/theInstalled.apk 3. Disconnect your Android phone 4. Run an instance of the Emulator 5. Now install the app on the emulator using the command adb -s emulator-5554 install c:theInstalledApp.apk adb -s emulator-5554 uninstall data/app/theInstalled.apk You should see a message indicating the size of the installed package, and Success.
  • 29. 29 Android Emulator 29 Android – Login into the OS shell 3. Android accepts a number of Linux shell commands including the useful set below ls ................. show directory (alphabetical order) mkdir .............. make a directory rmdir .............. remove directory rm -r .............. to delete folders with files rm ................. remove files mv ................. moving and renaming files cat ................ displaying short files cd ................. change current directory pwd ................ find out what directory you are in df ................. shows available disk space chmod .............. changes permissions on a file date ............... display date exit ............... terminate session
  • 30. 30 Android Emulator 30 Android – Login into the OS shell 4. There is no copy (cp) command in Android, but you could use the cat instead. For instance: # cat data/app/theInstalledApp.apk > cache/theInstalledApp.apk
  • 31. 31 Android Emulator 31 Using the Emulator with “inserted” SD card from Eclipse Additional Emulator Command Line Options: -sdcard c:Android_Emulator_Datamysdcard.img -datadir c:Android_Emulator_Data From Eclipse’s menu create new launch configuration: Run > Run Configurations > New icon On the Target panel 1. Select existing Android Virtual device (AVD) 2. Enter additional Command Line Options (see caption) 3. Apply > Run
  • 32. 32 Android Emulator 32 Sending Text Messages to the Emulator 1. Start the emulator. 2. Open a new shell and type : c:> adb devices so you know the emulator’s numeric port id (usually 5554, 5556, and so on) 3. Connect to the console using telnet command like: c:> telnet localhost 5554 4. After receiving the telnet prompt you can send a text message with the command (no quotes needed for the message) sms send <Sender’s phone number> <text message>
  • 34. 34 Android Emulator 34 Making a Voice Call to the Emulator 1. Start the emulator. 2. Open a new shell and type : adb devices to know the emulator’s numeric port id (usually 5554, 5556, and so on) 3. Connect to the console using telnet command like: telnet localhost 5554 (this is the ‘number’ to be called) 4. After receiving the telnet prompt you can place a call (voice) with the command gsm call <caller’s phone number>
  • 35. 35 Android Emulator 35 Example: Making a Phone Call to the Emulator
  • 36. 36 Android Emulator Using Eclipse’s DDMS facility 36 Emulator Control With these controls, you can simulate special device states and activities. Features include: 1. Telephony Status - change the state of the phone's Voice and Data plans (home, roaming, searching, etc.), and simulate different kinds of network Speed and Latency (GPRS, EDGE, UTMS, etc.). 2. Telephony Actions - perform simulated phone calls and SMS messages to the emulator. 3. Location Controls - send mock location data to the emulator so that you can perform location-aware operations like GPS mapping. To use the Location Controls, launch your application in the Android emulator and open DDMS. Click the Emulator Controls tab and scroll down to Location Controls. From here, you can: • Manually send individual longitude/latitude coordinates to the device. Click Manual, select the coordinate format, fill in the fields and click Send. • Use a GPX file describing a route for playback to the device.
  • 37. 37 Android Emulator 37 Using Eclipse to test Emulator’s Telephony Actions
  • 39. 39 Android Emulator 39 Appendix 1 – Connecting your Hardware Device to the Computer 1. Use a mini-USB cable to link the device and your computer 2. Expand the Notification bar 3. Mount the device You could now use the Eclipse-ADT-File Explorer panel to pull/push files to the device.
  • 40. 40 Android Emulator 40 Appendix 1 – Emulator to Emulator Communication 1. Run two instances of the emulator (typical IDs are: 5554, 5556, … ) 2. Dial (or send SMS) from one of them (say 5554) to the other (5556) 3. Press the Green/Red call buttons to accept/terminate the call 4. Try sending SMS (use numbers 5554 and 5556)