One of the Android Developer’s best friends is the emulator (aka AVD). It allows us to simulate some behaviors, like calling, sending SMS messages, simulate a specific location and much more. In this article, I’m gonna list some Android Virtual Device tips and tricks
Creating an emulator
Creating an Android Virtual Device is very simple.
avdmanager create avd \ --name myEmulator \ --device pixel_xl \ --sdcard 512M \ --package 'system-images;android-28;google_apis_playstore;x86'
To list the devices available run:
avdmanager list
To list the AVD created run:
emulator -list-avds
Running an emulator
To run an emulator you can run:
emulator run -avd myEmulator
Emulator keyboard mapping
In general, I use keyboard mappings for everything. I think it makes me more productive. AVD has some nice keyboard mappings to simulate the real experience closer to a real device.
MappingDescription
ESC | Back |
F4 | Hangup/end call button |
F7 | Power button |
F8 | Toggle cell networking on/off |
Ctrl + F5 | Audio volume up button |
Ctrl + F6 | Audio volume down button |
Ctrl + F11 | Change layout orientation |
See the complete list on the Android website
Logcat
One of the most important tools for the Android developer is logcat. Logcat is a simple way to see the system logs and debugging output from device/emulator. You can use logcat from an ADB shell to view the log messages.
adb logcat
Tips and tricks
The following commands need to be run using telnet
telnet localhost [emulator port]
Receiving a call
gsm call <telephone-number>
Receiving a SMS
sms send <telephone-number> <message>
Power battery
power capacity <battery %>
Network speed
network speed <download> <upload>
To see the list of available options type help
inside telnet’s prompt.