If you have worked with similar emulators in Eclipse before (or worked your way through Google’s Android developer reference), you’re probably familiar with the concept already. However, since Android seems to be attracting a lot of new developers, we’ll explain how to get access to Android’s Linux shell / emulator console in detail:
Accessing the emulator console:
(This will let you execute a number of commands to set the network speed dynamically, set up port redirects etc.)
- First, modify your launch configuration. Bring up the “Run” menu in Eclipse and select “Run…”. In the window that opens choose the “Emulator” tab and add “-console” to the command line options. Like so:
- Run your application and wait for the emulator to load.
- Next, fire up your favorite telnet client and connect to the console. The emulator will be listening on port 5554. If you have multiple instances of the emulator running, the second one will listen on port 5556, the third one on port 5558 etc.
This is what the result will look like (kindly disregard my ghetto telnet client):
In case you’re wondering what this is good for, an overview of the console commands is available here.
Accessing Android’s (Linux) shell:
This will give you the ability to execute your favorite POSIX commands and see what’s beneath Android’s pretty surface.
- First, launch your emulator. You can do that by running your application from Eclipse or manually from the command line.
- When the emulator is running, open a console on the host system. In Windows that simply means bringing up the command prompt window.
- If you haven’t added the Android SDK directory to your PATH evironment variable, navigate to the “tools” directory within manually. Next, connect to the running emulator instance by executing “adb shell”, which will bring up the shell prompt. Like so: