Instructions for using the Android emulator

Source: Internet
Author: User
Tags netspeed

1. Introduction of Android Simulator


Android provides a simulator to simulate arm-core mobile devices. The Android Simulator is based on QEMU, and Qemu is a well-known open-source virtual machine project (see http://bellard.org/qemu/), which provides a virtual arm mobile device. The Android emulator is named Goldfish to simulate an arm SoC that includes some of the following features:


* Arm926ej-s CPU


* THUMB Support


* MMC


* RTC


* Keyboard


* USB Gadget


* Framebuffer


* TTY Driver


* NAND FLASH


The source code for the Android emulator is mainly in the External/qemu directory. If you want to port Android to another device, familiarize yourself with the emulator environment it is currently targeting to provide some reference.


For developers of applications, the simulator provides a lot of development and testing convenience. Whether under Windows or Linux, the Android emulator runs smoothly, and Google provides the Eclipse plug-in that integrates the emulator into Eclipse's IDE environment. Of course, you can also launch the Android emulator from the command line.


This simulator features a very complete, phone book, call and other functions can be normal use (of course, you can't really call from here). Even its built-in browser and Google Maps can be networked. The user can use the keyboard input, mouse click the simulator key input, can even use the mouse to click, drag the screen to manipulate.


Of course the simulator is simulator, and the real machine or there is a difference,


The difference between Android simulator and real machine:


* Call and answer calls are not supported, but phone calls can be simulated via the console (inbound and outbound)
* USB Connection not supported


* Camera/video capture not supported


* Audio input (capture) is not supported, but output is supported (replay)


* Extended Headset not supported


* Unable to determine connection status


* Unable to determine battery level and AC charging status


* Unable to determine SD card insert/Eject


* Bluetooth not supported


2. Create and launch Android simulator


To play Gphone Simulator, of course, you need to go to http://developer.android.com/sdk first (if you can not open the http://androidappdocs.appspot.com/sdk/index.html) Download the Android SDK above, unzip it in the root directory of the SDK has a tools folder, which is the simulator and some very useful tools. (Please refer to http://blog.csdn.net/magicyu2/archive/2009/11/02/4755747.aspx for detailed installation procedure of SDK)


To properly start the simulation, you must first create an AVD (Android virtual device), you can use the AVD to create a different version of the emulator, the following describes how to create an AVD:


(1) View the currently supported version (in the listed version we need to remember the ID value, this value is used in the 2nd step):
[Email protected]:~$ android list target
You can see several available Android targets, such as: Name:android 1.6, they have their own ID number.
(2) Create an AVD:
[Email protected]:~$ android Create avd-n magicyu-t 2
-N followed by the need to create the name of the AVD,-t followed by the need to create the type of the virtual device, 2 is the type ID number obtained in step (1).
(3) To see if the creation was successful (if the AVD information we created earlier is displayed):
[Email protected]:~$ android List AVD
(4) Start the simulator:
[Email protected]:~$ emulator @magicyu or
EMULATOR-AVD Magicyu
where @ and-AVD followed by the name of the AVD you created.
(5) Select the skin to start
[Email protected]:~$ emulator-avd Magicyu-skin QVGA
After the skin is followed by the type of skins to be started, all types can be found in the <sdk>/platforms/android-1.*/skins directory, * for the indicated version. As in the 1.6 version of the SDK has HVGA,QVGA, wvga800,wvga854 several. Press CTRL+F11, you can directly change the vertical positioning of the simulator.



Of course the AVD can also be created and started in eclipse. For installation of ECLIPSE+ADT+SDK, see http://blog.csdn.net/magicyu2/archive/2009/11/02/4755747.aspx.


Run the eclipse,window->android SDK and AVD Manager to get the following interface, select New to create a new AVD.





Eclipse_create_avd


3. Some tools of Android simulator


(1) ADB:


ADB (Android Debug Bridge) is a generic debugging tool provided by Android, and with this tool we can manage the status of the device or phone simulator and do the following:


A, quickly update the device or the code in the phone simulator, such as app or Android system upgrade;


b, run the shell command on the device;


C, management equipment or mobile phone simulator on the predetermined port;


d. Copy or paste files on the device or phone simulator


Some common operations:


Enter SHELL:ADB Shell


From the above command, you can enter the device or emulator shell environment, in this Linux shell, you can execute a variety of Linux commands, in addition, if you want to execute only one shell command, you can use the following way:


ADB Shell [command]


For example, the ADB shell DMESG will print out debug information for the kernel.


(Android's Linux shell is a lot leaner and many Linux commands are not supported)


Uploading files: adb push <pc file > </tmp/...>


Download files: adb pull </tmp/...> <pc file >


Installer: adb install <*.apk>


Uninstall software: adb shell rm/data/app/<*.apk>


To add, the software installed through ADB (*.apk) is in the "/data/app/" directory, so the installation does not have to set the path, uninstall just need to simply execute "RM" on the line.


End ADB:ADB Kill-server


Show Android Emulator Status:


ADB devices (port information)


ADB get-product (device model)


ADB Get-serialno (serial number)


Waiting for a running device: ADB wait-for-device


Port forwarding: adb forward adb forward tcp:5555 tcp:1234


(Forwards the default port TCP 5555 to port 1234)


View bug report: ADB bugreport


ADB shell sqlite3 Access database SQLite3


ADB shell Logcat-b Radio record Wireless communication log: In general, the wireless communication log is very much, at run time not necessary to record, but we can still through the command, set the record





Application configuration file:


In "Androidmanifest.xml"


"<category android:name=" Android.intent.category.LAUNCHER "/>"


Decide whether the application is displayed on the panel





(2) am instruction (use AM in the shell to load Android apps):


AM [Start|instrument]





Am start [-a <action>]


[-D ]


[-t <mime_type>]


[-C <CATEGORY> [-C <category>] ...]


[-E <EXTRA_KEY> <EXTRA_VALUE> [-e <EXTRA_KEY> <EXTRA_VALUE> ...]


[-n <component>] [-d] [<uri>]


AM Instrument [-e <ARG_NAME> <arg_value>]


[-P <prof_file>]


[-W] <COMPONENT>


To start the browser:


Am Start-a android.intent.action.view-d http://www.google.cn/


Dial number:


Am Start-a android.intent.action.call-d tel:10086


Launch Google Map direct to Beijing:


Am Start-a Android.intent.action.VIEW geo:0,0?q=beijing





(3) Add the SD card to the simulator:


Emulator-sdcard <path>/sdcard.img


Now let's talk about how to create a "sdcard.img" file:


"Tools" Directory there is another very useful tool mksdcard, a look at the name will know--make SDcard. Yes, use it to create an "SD card".


The command is:


Mksdcard 1024M d:/sdcard.img


OK, so an SD card with a capacity of 1G is created.


Using SDcard:


Created: Mksdcard <1024M> <sdcard.img>
(bytes (default), K,m)


Connect to Simulator: Emulator-sdcard <path/sdcard.img>


Upload files to sdcard:adb push < catalog/audio.mp3> </sdcard/audio.mp3>





(4) Android simulator call to send SMS


Gphone Simulator has a unique number: 15555218135, this is similar to our physical phone SIM card number. To implement dial-up, use your phone? Of course not!


More simple, three steps:


1. Open the terminal


2. Connection: telnet localhost 5554 (5554 is the number shown above when you open the simulator)


3. Command: GSM call 15555218135


look! Does the caller appear on the simulator? Answer/Hang-up is the same as the physical phone.


Texting is as simple as repeating the above 1, 22 steps, the third command change:


SMS Send 15555218135 hello,this is a Message.





4, Android Simulator main command parameter introduction


Emulator [-<option> [<value>]] ... [-<qemu Args>]
The following table summarizes the available parameters


Help


-help the list of print emulator parameters.


-help-all Print all startup parameter details.


-help-<option> Prints the information that specifies the startup parameters.


-help-debug-tags Print all the lists that are-debug <tags> open.


-help-disk-images Prints the disk image information that is in use.


-help-environment Print Simulator environment variable information.


-help-keys prints the current keyboard map.


-help-keyset-file print the definition of a custom keyboard mapping file.





Disk Images


-cache <filepath> Use <filepath> to specify a network cache partition image.


Custom, you can specify a relative path to the current working directory. If you do not specify a cache file, the emulator specifies a zero file as the cache file. Please refer to-help-disk-images for more information.


-data <filepath> use <filepath> as user data disk mirroring.


Custom, you can specify a relative path to the current working directory. If-data is not used, the emulator will look for an image file called "Userdata-qemu.img" in the directory specified by <datadir>. By default, the emulator will look for ~/.android (on Linux/mac) or C:/Documents and settings/<user>/local settings/application Data/ Android (on Windows).


If you use-data <filepath&gt, but the file does not exist, the emulator creates a file with the same name.


For more information, see Running multiple emulator instances and-help-disk-images.


-image <filepath> use <filepath> as a system image.


Custom, you can specify a relative path to the current working directory. The default is <system>/system.img.
-initdata <filepath>


When overriding user data mirroring, (using-wipe-data), copy the contents of this file to the new user data file image. By default, the emulator copies the <system>/userdata.img.


Custom, you can specify a relative path to the current working directory. See-wipe-data.


For more information, see-help-disk-images.


-kernel <filepath> use <filepath> as the simulator kernel. Custom, you can specify a relative path to the current working directory.


-nocache no cache partition when starting the emulator. See-cache <file>.


-ramdisk <filepath> use <filepath> as a virtual memory image. The default is <system>/ramdisk.img. Custom, you can specify a relative path to the current working directory. For more information, see-help-disk-images.


-sdcard <filepath> use <file> as an SD card image. The default is <system>/sdcard.img. Custom, you can specify a relative path to the current working directory. For more information, see-help-disk-images.


-system <dirpath> Search system, virtual memory and user data image files under specified <dir>. <dir> is the relative directory for the current path.


-wipe-data to the user data image file. (That is, the file specified By-datadir and-data, or the default file). The emulator deletes all user data and then copies the data specified by the right-inidata parameter to the image file before it is started. See-initdata. For more information, see-help-disk-images.


Debug


-debug <tags> switch on/off the debug information for the specified tag.


<tags> is a list of debug build names that are separated by a space/comma/column. See-help-debug-tags for more information.


-debug-<tag> Toggle the debug information for the specified tag on/off. Use-help-debug-tags to get a list of debug components that you can specify as <tag>.


-debug-no-<tag> closes the debug information for the specified tag.


-logcat <logtags> Opens the log output for the specified tag. If the environment variable android_log_tags is specified and is not empty, her value becomes the default value for the log output.


-shell Create a command-line window with root privileges. You can still use the command-line window even if the emulator's UI interface is not available. Press the CTR-C key to interrupt the emulator to run.


-shell-serial <device> Open a script window with root permissions. <device> must be a QEMU-type device. See ' Serial-dev ' on http://www.bellard.org/qemu/qemu-doc.html#SEC10 for list information about device types. Here are some examples:


· -shell-serial Stdio is identical To-shell


· -shell-serial tcp::4444,server,nowait allows your shell to communicate over 4444 ports.


· The-shell-serial Fdpair:3:6 allows the simulator to use 3 (in) and 6 (out) disk drives.


· -shell-serial Fdpair:0:1 uses the normal stdin and stdout FDS, except that QEMU won ' t tty-cook the data.


-show-kernel <name> display kernel information.


-trace <name>enable Code profiling (press F9 to start), written to a specified file.


-verbose open verbose output. Equivalent to-debug-init. You can define ANDROID_VERBOSE environment variables as verbose output parameters. Define the parameters you want to use, separated by commas. This can omit parameters such as-debug-<tags>. Here is an example of setting up Android_verbose with the-debug-init and-debug-modem parameters:


Android_verbose=init,modem for more information see <-help-debug-tags>.


Media
-audio <backend> uses the specified audio back end.


-audio-in <backend> uses the specified audio input back end.


-audio-out <backend> uses the specified audio output back end.


-noaudio Turn off audio support in the current virtual machine instance.


-radio <device> redirect The Radio interface to a local byte device.


-useaudio Open Audio support for the emulator instance. The default is open.


Network


-dns-server <servers> uses the specified DNS server. <servers> must be a comma-separated, more than 4 server name or IP address.


-http-proxy <proxy> Configure a TCP connection using the Http/https proxy.


<proxy> must conform to the following format:http://<server>:<port>


The http://<username>:<password>@<server>:<port> prefix http://Can be ignored. If-http-proxy <proxy> is not specified, the emulator will look for Http_proxy environment variables and automatically look for the <proxy> values for all symbol formatting requirements.


-netdelay <delay> Set Network latency defaults to none. See the values for <delay> in Network Delay emulation.


-netfast Fast-netspeed Full-netdelay None


-netspeed <speed> Specify simulator network speed is <speed>. The default value is full. See the <speed> Values in table network speed Emulation.


-port <port> Specify the simulator network port to <port> The console number must be between 5554 and 5584, and <port>+1 must be reserved for ADB use.


-report-console <socket> before booting to a third party comrade the network port of this emulator instance. <socket> must be in the following formats


Tcp:<port>[,server][,max=<seconds>]


Unix:<port>[,server][,max=<seconds>]


For more information see-help-report-console
System


-cpu-delay <delay> lower the simulator CPU speed to <delay>. <delay> supports integers from 0 to 100. Note <delay> is independent of the specific clock or other absolute frequency. It is only represented as an abstract, relative to the current emulator's health speed adjustment.


-gps <device> redirect Nmea GPs to byte device.


Use this parameter to notify the emulator to impersonate a nmea-compatible GPS, to connect to an extended device or socket port. The <device> format must conform to the device format specified by qemu-specific. For more information, see ' Serial-dev ' and http://www.bellard.org/qemu/qemu-doc.html#SEC10.


-nojni to turn off jni checking while Dalvik is running


-qemu pass parameters to QEMU.


-qemu-h turn off QEMU help.


-radio <device> redirect Recorder module to the developed character device. The <device> format must conform to the serial device specified by QEMU. See http://www.bellard.org/qemu/qemu-doc.html#SEC10 for details.


-timezone <timezone> Set the simulator time zone to <timezone&gt, and replace with the system time zone. <timezone> must be specified in the time zone format. For example: "America/los_angeles", "Europe/paris"


-version Displays the simulator version number.


Ui


-dpi-device <dpi> Modify the simulator's resolution to fit the physical device. The default value is 165. See-scale.


-no-boot-anim turns off the animation when the emulator starts. Disabling the start animation can speed up startup.


-no-window closes the drawing window of the emulator.


-scale <scale> Adjust Emulator window. <scale> is a number from 0.1 to 3, which is the scale factor for adjusting the screen. You can also specify a DPI value in the case of adding a DPI prefix. The auto parameter tells the simulator to choose the size that suits you best.


-raw-keys turn off the Unicode keyboard reverse-mapping.


-noskin does not use any simulator skins.


-keyset <file> replaces the default with the specified keyboard settings file. Specifies the keyboard mapping file between the host keyboard and the emulator. See-help-keyset for more information.


-onion <image> Overlay the screen with pictures. JPEG not supported, PNG only supported


-onion-alpha <percent> Specify onion skin transparency value (percent) defaults to 50.


-onion-rotation <position> specifies onion skin rotation. <position> must be one of 0, 1, 2, 3.


-skin <skinID> launch simulator with specified skin.


-skindir <dir> Search for skins under specified directory <dir>

Instructions for using the Android emulator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.