Monday, September 29, 2008

[How-To] Android emulator

(1) How to install emulator only (that is no JDK, Eclipse IDE or compiler)

(a) Download Android SDK from
http://code.google.com/android/download_list.html

The current version is
android-sdk-windows-1.0_r1.zip (windows)
android-sdk-linux_x86-1.0_r1.zip (linux)

unzip it and put the folder (android-sdk-windows-1.0_r1) to say under

Windows OS

D:\Android\


Linux / Mac OS X

~/Android/


(b) start the emulator in command windows (windows-R -> cmd) / (Linux/Mac OS X -> Terminal) for the first time to setup data directory

Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
emulator -datadir D:\Android


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./emulator -datadir ~/Android


(2) How to create sdcard for emulator (e.g. 500M)
e.g. To create a sdcard image of 500M with filename sd500m.img

Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
mksdcard -l SD500M 500M D:\Android\sd500m.img


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./mksdcard -l SD500M 500M ~/Android/sd500m.img


when starting the emulator and adding -sdcard option
Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
emulator -sdcard D:\Android\sd500m.img [.... other options]


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./emulator -sdcard ~/Android/sd500m.img [.... other options]


(3) How to scale the emulator size when the emulator screen is out of view of your computer

when starting the emulator and adding -scale option (range from 0.1 to 3)

e.g. start the emulator with a scale of 0.5
Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
emulator -scale 0.5 [.... other options]


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./emulator -scale 0.5 [.... other options]


(4) How to copy Musics and Pictures to the sdcard image for Android emulator

The sdcard image is a FAT32 image. You just double click the file in Mac OSX to mount it.
Inside it, create folders called Musics and Pictures and put your mp3 files and pictures as per screen dump below

(5) How to copy files to sdcard while the emulator is running or when you cannot mount it.

You can mount the sdcard image while the emulator is running, but sometimes you want to copy files to the sdcard in command line mode run this

Make Sure that the emulator is running
Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
adb push mynotebookphoto.png sdcard/Pictures/


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./adb push mynotebookphoto.png sdcard/Pictures/


However, the emulator will need to restart so that it can acknowledge the new file. This is currently the limitation of the emulator

when copying back from emulator sdcard to local file
Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
adb pull sdcard/Pictures/image01.jpg images01_fromsdcard.jpg


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./adb pull sdcard/Pictures/image01.jpg images01_fromsdcard.jpg


(6) How to get shell access to emulator
The emulator must be running, and run this
Windows OS

D:
cd D:\Android\android-sdk-windows-1.0_r1\tools
adb shell


Linux / Mac OS X

cd ~/Android/android-sdk-linux_x86-1.0_r1/tools
./adb shell


(7) How to add path of the emulator tools directory to Windows OS, so as no need to change directory to sdk directory
On Windows, right click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, double-click on Path under System Variables and add this to end of the text
Windows OS

D:\Android\android-sdk-windows-1.0_r1\tools;


Please take note that you have to restart the command window for the path to become effective

(8) How to change skin for the emulator
You can download some iPhone skins for Android emulator here

http://www.anddev.org/emulator_iphone_skin_-_qvga-hvga_landscape-portrait-t109.html

(9) How to change wallpaper, add new icons to homescreen and move/delete icons.

At Home Screen, press Menu

+ Add -> for adding icons to home screen
Wallpaper -> to change wallpaper

You can flip the homescreen to left and right and add icons there

To delete the icon just click and hold the button and a trash will appear above the menu button then you can drag the icon to the trash and delete it

To move the icon, click and hold the icon and then drag to new position.

5 comments:

ppmoore said...

Very useful thanks, Paul

dinjas said...

Thanks, the sdcard part was just what I was looking for

Chaudhry said...

Hi I am getting the following error, any advise?

"D:\android\tools>emulator: ERROR: You did not specify a virtual device name, and
the system
directory could not be found.

If you are an Android SDK user, please use '@' or '-avd '
to start a given virtual device (see -help-avd for details).

Otherwise, follow the instructions in -help-disk-images to start the emulator"

Android Tips said...

Just now installed and using it..it is running a bit slow on my system bcz I'm using a dual core processor but hopes to be working fast in my friend's i7 processor..I'm happy to have my new Android and that too free..hehehe :)
Really great and thanx to haseeb too...

Jual Lingerie said...

Thanks for great article.