Links you will need:
The best tutorial I could find.
How Do I Install the Android Market on Android SDK - Tech-Recipes
System image file with Market and GoogleServicesFramework installed
system.img
Just read the first link to get a general feel for what is going on. Even try it if you want too, but I tried several times with 2.2, 2.3, and 4.0 and the Market app was not there in the end.
Finally I decided to read the comments and found the link to the system image file (second link). With it you only need to create an emulator in the avd manager and then go in username/.android/avd/whatever you named it and paste the system image file into it. Then run the launch the emulator normally.
The kicker is that the version of the Market in the image file is limited and will not download.
I got the Vending.apk off my phone and sent it to the computer and placed it into my sdk/tools folder. I typed the following commands into the command prompt.
emulator -avd Market2 -partition-size 200 (Market2 being the name of my avd)
(this will launch your emulator, just wait until it is fully loaded and you can look in app drawer and verify the Market it there)
Then back in the Command window, type the following.
adb shell "mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system"
adb shell "chmod 777 /system/app"
adb push Vending.apk /system/app/. (wait till you see Success)
Go back to the emulator and bring up the market and sigh in etc. Still not great selection, but you can get some apps and actually download and install them.
Here is the problem. After you close the emulator down, it reverts back to the system image file with the original vending apk installed. Jerked my chain, but this is no different than following all the instructions and finding on relaunch the Market is not there.
So what I did was write a batch file to do all this stuff so I would not have to use the command prompt and type it all in every time I wanted to use it.
Copy the following into a notepad file and edit it for your machine and avd then save it to your desktop as a .bat file. It will launch everything and will have the working market Vendor app there. Do not close the command window that is generated, just minimize it while you are using the emulator,
------------------------------------------------------------------------
cd C:\android\tools
emulator -avd Market2 -partition-size 200
pause
adb shell "mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system"
adb shell "chmod 777 /system/app"
adb push Vending.apk /system/app/.
pause
--------------------------------------------------------------------------The first line changes your command window to your Android\tools folder is where you will have the updated Vending.apk
The pause instructions will place command window in a wait stage until you hit a key. Do not hit a key until the emulator is fully loaded.
The next 3 lines get you into read/write mode for /system/app and get the permissions set, then pushes the Vending file in to the /system/app.
Do not do anything until you see "success" and then minimize the command window.
Go back to the emulator and do what ever you want in the Market.
Note you can install all apps that are not System apps. Like I placed Astro File Manager, apkinstaller, and Gmail into my /tools folder and from the command prompt typed adb install Gmail.apk. They all installed and were in there the next time I loaded the emulator.
I hope I got it all. This has been a frustrating project for a Boot Camp like me.