banner 1
Tips for Android Sdk Emulator | With the growth of mobile browsing, AddThis has continually improved and optimized layouts, sprites and other elements to make sure that our standard suite of tools works well wherever they are used. Luckily you can use the
Android Emulator, part of the
Android SDK Emulator. It’s more accurate than user agent switching, and closer to home than remote VMs, allowing for some interesting remote debugging options.
Once you’ve got the SDK installed, most of the techniques should be applicable on all operating systems. my be your like see this
Android games
Brewing Your Android
You only need a few of the command line tools from the SDK in order to use the Android Emulator to debug websites; in my experience, “android”, “emulator”, and “adb” (Android Device Bridge). On Macintosh OS X, you can install the SDK which includes these tools using the great package manager, homebrew.
brew install android-sdk
export ANDROID_HOME=/usr/local/opt/android-sdk
Android is not a single OS/version. To install all of the platforms you don’t have, run:
android update sdk --no-ui --filter platform
android update sdk --no-ui --filter system-images
Update your base SDK tools and platform tools with:
android update sdk --no-ui --filter tool,platform-tool
These are all of the named filters you can use: add-on, doc, extra, platform, platform-tool, sample, source, system-image, tool
If you want to see a list of everything you haven’t installed, run:
android list sdk
android update sdk --no-ui --filter 4,5,6
Here Loggy, Loggy
The logcat tool, part of adb (Android Device Bridge), allows you to ‘tail’ the logging output from an Android device or emulated device (AVD, Android Virtual Device). adb -e logcat -v time WebCore:V browser:V *:S
Goodbye QEMU, Hello HAXM
The “regular” QEMU based emulator is slow. There are multiple layers of code translation involved as commands are converted into the Dalvik VM (this is Android’s final virtual machine) code used by the emulated device. Install Intel HAXM and forget about QEMU. Open up the Android Virtual Device (avd) manager with the command:
android avd
Change the name and change the processor type to “Intel Atom”. As with tip #4, open up the AVD manager with the command:
android avd
Some apps may require the Host GPU setting, so if you experience difficulty, try changing from using snapshots to “Use Host GPU”.
The “emulator” command line tool has more, powerful, command line options than you can shake a stick at. Emulator Command Line Options
The emulator tool’s disk image options allow you a lot of flexibility in pre-configuring your Android Virtual Devices, and the debug and network options are quite useful as well.
Phone Bank
Luckily there’s a project to create a shared repository of AVDs (Android Virtual Devices). The AVDs consist of a config-like .ini file normally located at ~/.android/avd and a directory which contains the AVDs themselves. The “linkavd” script will replace the devices.xml file in ~/.android/ and create .ini files and link to them from ~/.android/avd. Please do NOT run the script if you have a bunch of preexisting AVDs or device definitions that you care about. If you do have pre-existing AVDs or devices, please consider contributing them to the repository.
You can have multiple hardware Android devices connected, and multiple Android Emulator instances running. When this happens, and you need to run one of the “adb” commands, you need to specify which device is the target of the command. To target the only device attached, use adb -d <your command>. To target the only emulator, use adb -e <your command>. The serial number is the device type, then “-”, then the port number. That means this device’s serial number is “emulator-5554″. You can get a list of connected devices by executing adb devices from the command line. After you’ve found the proper serial number, you’ll execute a command targeting that device that looks something like this:
adb -s emulator-5554 install jsHybugger.apk
The Android Emulator has keyboard commands that allow you to do this, among other things, but the keyboard mappings can be very difficult to work with. By running emulator -help-keys you can view the default key mappings:
HOME Home button
ESCAPE Back button
F3 Call/Dial button
F7 Power button
F5 Search button
KEYPAD_PLUS, Ctrl-F5 Volume up button
KEYPAD_MINUS, Ctrl-F6 Volume down button
Ctrl-KEYPAD_5, Ctrl-F3 Camera button
KEYPAD_7, Ctrl-F11 Switch to previous layout
F9 Toggle code profiling
Alt-ENTER Toggle fullscreen mode
DELETE Show trackball
KEYPAD_5 DPad center
KEYPAD_4 DPad left
KEYPAD_6 DPad right
KEYPAD_8 DPad up
KEYPAD_2 DPad down
KEYPAD_MULTIPLY Increase onion alpha
KEYPAD_DIVIDE Decrease onion alpha
An example of directly launching an emulator with a specific keyboard mapping keyset file:
emulator -avd MyAVD -keyset mykeyset
Note that “mykeyset” here is actually a file named “mykeyset.keyset” that is located either in the ~/.android/ folder, a “keysets” folder in the system directory, or a “keysets” folder of the program directory (e.g. the tools directory, I think).
Here’s what I have changed in my default.keyset in order to simplify the orientation change commands:
CHANGE_LAYOUT_PREV Keypad_7, Ctrl-F11, RCtrl-F11, Ctrl-P, RCtrl-P
CHANGE_LAYOUT_NEXT Keypad_9, Ctrl-F12, RCtrl-F11, Ctrl-L, RCtrl-L
As an alternative, open up a software keyboard program and use that to control your emulator with the default key commands.
How can you do it with the Android tools? adb shell screencap -p | sed 's/\r$//' > screen.png
This will save a screenshot from your Android device or emulator as “screen.png” in the current directory. Once you’ve got your AVDs singing, it’s time to look at remote debugging options.
It’s called the SDK Emulator, originally designed for developers to test their apps with the newest platforms with different configurations.
First of all, let’s setup the Android SDK, which we need to configure and run the emulator.
Download and unzip the specific Android SDK version for your OS from the developer site. If you’re on Windows, execute “SDK Manager”, if you’re on Linux or a Mac, navigate to /tools and execute “android”. In the SDK setup, go to “Available Packages” and select the packages you want, for example “SDK Platform Android 2.3, API 9, revision 1″, than click “Install selected”. Don’t forget to select “Android SDK Tools, revision 8″ as well.
You’re being prompted with the License Agreements. If you’ve done that, click “Install”.
Relax and take a cup of coffee. Go to “Virtual Devices”
Click “New”
You get prompted with an setup screen. In “Name”, enter your desired name for the emulator device.
In “SD Card”, choose file, than enter 200. VoilĂ , your virtual Android device has been configured.
Type “cd /Path/To/The/SDK/Tools”. Now type “emulator -avd <AVD-name>, and here it is: Your very own Android emulator.
Enjoy.
banner