Post on 15-May-2015
description
By Mike Wolfson@mikewolfson
Test and Debug with Android Dev Tools
San Francisco, CA March 8, 2011
Session Overview
• Emulator• DDMS• ADB• Hierarchy Viewer• Other important tools
Why are we here?
Fit and Finish
• What it is• Capabilities• Limitations• SDK and AVD Manager
Emulator - control
• What’s an Android Virtual Device?• Creating Custom AVDs–Using Skins
• Speed it up–Disable boot & other animation–Leave it up–Honeycomb – change RAM to 1GB
• Using “Snapshot” to save emulator state
Emulator - AVDs
• Hacking the emulator–Scale factor (0.1 – 3)–File system access (\.android\avd)–Accessing the Market• http://developer.htc.com/google-io-
device.html#s3
Emulator - AVDs
Emulator - control
• Key Commands: emulator –help-keys–Switch orientation: • Cntrl-F12; KEYPAD_9; Ctrl+Cmd+F11
–Home: Home; Back: Esc–Call\Dial: F3–Camera: Ctrl-KEYPAD_5–Fullscreen Toggle: Alt-Enter
• How DDMS Works• Starting DDMS–From Eclipse–From Command Line
• Devices• Tip: File>Preferences
DDMS – Dalvik Debug Monitor Service
• Logcat–Different Levels–Viewing from DDMS–Controlling from command line
• Tip– final static boolean DEBUG_MODE = false;
if (DEBUG_MODE) Log.i(LOG_TAG,"Load level: " + mLevel);
DDMS – Logs and output
• V- Verbose• D- Debug• I – Info• W – Warning• E- Error• F- Fatal• S- Silent
DDMS – Logcat settings
•Memory–View Heap Usage–Tracking memory allocation
• Threads•Garbage Collection
DDMS – Memory and File Explorer
• Simulate Events–Telephony (Status & Actions)–Location•Capture screen images• File Explorer
DDMS – Simulating Events & Extras
• What it is• Command control of device–adb devices–adb -s emulator-5556 install
helloWorld.apk–adb install c:\myapp\app.apk
ADB – Android Device Bridge
• Emulator• Device–Install USB Driver• http://developer.android.com/sdk/oem-
usb.html–On Device: Applications > Development,
then enable USB debugging.
ADB – Debugging
• Using the app• Run on emulator–Run on device
• Settings
Dev Tools App
•What it is• How to run• Layout View• Pixel Perfect View• Alternative: layoutopt tool
Hierarchy Viewer
• Control via scripts• Test\control multiple devices at once• Functional and regression testing• The API• Running it
Monkey Runner
Other Tools
• Traceview• Proguard• MonkeyRunner• Command Line
Conclusion
Performance problems are bugs. Find them quickly
and easily – and fix them!
Confused? Questions?
@mikewolfson