Monday, September 6, 2010

How to use Android Market on Android Emulator 2.2

After some digging, finally I got android market working on Android emulator 2.2 running on Windows Vista. Here is the steps,:
  • Start SDK Setup.exe and create an AVD - android-2.2
  • Copy system.img coming with the SDK platform to the newly created AVD.
cd c:\Users\dliu\.android\avd\android-2.2.avd
copy c:\labs\android-sdk-windows\platforms\android-8\images\system.img .
  • Start the emulator by using command line:
c:\labs\android-sdk-windows\tools>emulator -avd android-2.2 -partition-size 96
  • Pull build.prop from the emulator for editing:
c:\labs\android-sdk-windows\tools>adb.exe pull /system/build.prop .
  • Comment out ro.config.nocheckin=yes line from the build.prop file just pulled out from the emulator.
  • Push back the updated build.prop file to the emuloator
C:\labs\android-sdk-windows\tools>adb.exe remount
C:\labs\android-sdk-windows\tools>adb.exe push build.prop /system/build.prop
C:\labs\android-sdk-windows\tools>adb.exe push c:\labs\r21-update-nexusone-modacocustomcustomrom-withadditions-chinese-signed\system\app\GoogleServicesFramework.apk /system/app
C:\labs\android-sdk-windows\tools>adb.exe push c:\labs\r21-update-nexusone-modacocustomcustomrom-withadditions-chinese-signed\system\app\Vending.apk /
system/app
C:\labs\android-sdk-windows\tools>adb shell rm /system/app/SdkSetup.apk
  • Stop the emulator and delete the files: userdata-qemu.img, userdata.img, cache.img
  • start the emulator by using command line again, you should get the Android Market in your emulator.

34 comments:

  1. Thank you for the tutorial, I greatly appreciate it. I noticed that I am unable to find all of the apps in the Market that are available on my physical Android device. Have you seen similar behavior?

    ReplyDelete
  2. @Brian, Yes, I also noticed that I could not find all of the apps in the Market.

    ReplyDelete
  3. THANKS! I needed to test a feature of my app using 2.2 and the market. Your tutorial totally worked.

    ReplyDelete
  4. Can you please translate these commands for linux users.

    for pull build.prop i tried
    ./adb pull /home/varun/android-dk-linux_86/platforms/android-8/build.prop .

    and i got an error:
    remote object '/home/varun/android-sdk-linux_86/platforms/android-8/build.prop' does not exist

    What am i doing wrong?

    ReplyDelete
  5. Linux Users

    1. Create your avd using either terminal or gui.

    A. Terminal - cd to the location of your SDK tools folder and run
    ./android create avd -n android-2.2 -t 7

    B. Gui - run ./android from you SDK tools folder and make a new 2.2 virtual device
    named android-2.2

    *Note - Replace the 7 in the terminal with whatever 2.2 is for you. You can find out by running
    ./android list target


    2. Copy the system.img from your sdk using the terminal or manually

    Terminal - cp /home/USER/location of sdk/platforms/android-8/images/system.img ~/.android/avd/android-2.2.avd


    3. Start the emulator using either the terminal or gui

    A. For terminal (Make sure your in your SDK tools folder) - ./emulator -avd android-2.2 -partition-size 96


    4. After the emulator has fully started we need to pull build.prop (Open a terminal if needed and go to the tools folder)

    A. Terminal - ./adb pull /system/build.prop

    *Note - Open a new terminal or a new tab and cd back to the tools folder of the sdk.


    5. Comment out ro.config.nochecking=yes from the file by putting a # in front of the line.

    A. Terminal - gedit build.prop

    B. Save changes and exit


    6. Push back the update build.prop

    Terminal - ./adb remount

    ./adb push build.prop /system/build.prop

    7. Get the custom rom linked above. Extract it to your desktop and rename the folder
    to r21


    8. Run the following commands in the terminal

    ./adb push ~/Desktop/r21/system/app/GoogleServicesFramework.apk /system/app

    ./adb push ~/Desktop/r21/system/app/Vending.apk /system/app


    9. Remove the SdkSetup file

    ./adb shell rm /system/app/SdkSetup.apk


    10. Finally stop the emulator and run these commands in terminal

    cd ~/.android/avd/android-2.2.avd

    rm -R userdata-qemu.img userdata.img cache.img


    11. Start up the emulator and you should now have the market!

    ReplyDelete
  6. Everytime I get to the step of pushing the modified build.prop file back to the emulator, I get the error, "Failed to copy 'build.prop' to '/system/build.prop': Out of memory". I have tried this on an XP VM, an XP real box, and an Ubuntu 10.4 machine following the provided Linux users instructions and get the same error on every machine. Can anyone help? Thanks!

    ReplyDelete
  7. Thanks David!
    I've been struggling with this for two days, and you're the only one I've found who did it.
    You rock!
    D.

    ReplyDelete
  8. excellent method! works great. Been trying for quite a while without success. The only thing is that the Vending.apk from Modaco seems to be missing many many apps. Can we simply remove the vending.apk and push another one instead? If so, which would you suggest?

    ReplyDelete
  9. I am not an Android application developer but just want to try out Android application before installing them to my device. I successfully installed the SDK Manager in my Windows XP and created an AVD. I am also able to start the AVD in the SDK manager. However, I am not able to follow the steps you mentioned here. I even cannot find the "system.img" in any directory, let alone copying it to AVD folder. I also has no idea what command line is....

    I will very much appreciate if a step by step instruction can be provided here for Windows XP users.

    ReplyDelete
  10. Thanks for the tutorial. I have been searching for MONTHS on a guide just like yours! I want to use an AVD for a little Android training session I will be doing to help train some peers on the platform. Having the Market is a MUST. I have this working somewhat now based on your info but I have a couple of problems 1) I had to use a different source I found for the Android 2.2 .APKs since the Modaco link was broken. Is there another suggested source you have which is known to work 2) When I follow these steps it seems that the home button for this AVD is broken within the emulator program. Anyone else seen this and is there a fix? 3) I cannot find many apps in the market. I am not sure how the version of Vending.apk effects this since the list is being updated constantly and its suppsed to pull live data from the network. Is there a fix for this?
    4) Can I use custom command line options such as a partition-size larger than 96MB if I want more space on the AVD? Can I launch the AVD through the AVD Manager tool or do I always have to use the command line you listed from now on with this VM?

    Any suggestions or comments on any of these questions would be greatly appreciated?

    ReplyDelete
  11. I have done everything , i cant find Market in emulator...

    ReplyDelete
  12. Followed all the steps too, verified that build.prop has line commented out and Vending and GoogleServicesFramework is present in appropriate locations. Added my google account to the device. Still no Android Market. Any ideas what to do?

    ReplyDelete
  13. I am able to get Android Market in My Froyo(Android 2.2) Emulator. But I am not able to find and install any flash player using this Android market App for my Emulator.
    Any pointer would be really appreciated!!

    Thanks,
    Pranjal

    ReplyDelete
  14. Doesn't work at all the Market Icon doesn't come up

    ReplyDelete
  15. Hi David,

    Thanks for the post. It works for me. I have put up a short post regarding this.

    http://techdroid.kbeanie.com/2011/01/android-market-on-emulator-22.html

    ReplyDelete
  16. solved but it's useless beacouse practically no app is available like facebook and so on

    ReplyDelete
  17. Thank you very much. It worked out for me. Could u plz help me how to work with Cloud to Device Messaging using push api

    ReplyDelete
  18. I'm newbie for programming and never school about it, just see from other blog. I has been use Android Emulator 1.6 but I wanna to use new version. So today, I'm try your post.

    I type D:>Program Files/Android/android-sdk-windows/tools>emulator -avd MyMarket22 -partition-size 96

    on cmd and it's work. I was waited until Startup finish. But I can't type anything...

    I was tried open new cmd (without closed SDK), and type
    D:>Program Files/Android/android-sdk-windows/tools>adb.exe pull /system/build.prop

    but it's not work!!

    I'm using Windows XP in 32byte.
    Sorry if my english too bad... :P

    ReplyDelete
  19. finally... I get it... hohohohoho... I was wrong type.

    ReplyDelete
  20. hey i followed your step(Linux user Commented by Gage)..Till 3rd it was workin fine..but i am getting error ./adb not found i,e

    . After the emulator has fully started we need to pull build.prop (Open a terminal if needed and go to the tools folder)

    A. Terminal - ./adb pull /system/build.prop

    *Note - Open a new terminal or a new tab and cd back to the tools folder of the sdk.
    please help..Thanx in advance

    ReplyDelete
  21. i got adb that was in platform-tools folder not in tools...but agian after running that line getting error:
    device not found..what should i do now?i have already opened emulator

    ReplyDelete
  22. $android-sdk/platform-tools/adbadb push file /system/..

    and meet problems like “failed to copy file to /system/…”, such as:

    failed to copy ‘file’ to ‘/system/…’: No space left on device
    failed to copy ‘file’ to ‘/system/…’: Out of memory

    Don't use AVD Manager to start the Android emulator, use the command line:

    $android-sdk/tools/emulator–avd youravdname –partition-size 128

    then
    $android-sdk/platform-tools/adb remount

    Then you can try the command “adb push file /system/…”, and the problem maybe resolved.

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete
  24. David,

    Thank you very much for the tutorial for copying 2.2 sys img. When I go to copy it, I get a message saying file cannot be found. I moved the sys.img file to one the folders in my sdk platform folders even so I could easily find it. Any ideas to what I may be doing wrong here. Thank you for your time in posting your comments

    ReplyDelete
  25. Thank you, but I don't understant, my appmarket is not full. It miss lot of applications :(

    ReplyDelete
  26. For Linux-Users not finding the "adb" command.

    The Readme states:

    The adb tool has moved to platform-tools/

    So the adb command is no longer in the tools directory, but in a directory called platform-tools.

    Just cd there and everything should work fine.

    ReplyDelete
  27. my emulator is not starting. It just flashes a cmd type of window for a second,and then nothig appears after that......

    ReplyDelete
  28. Has anyone gotten more apps to show up on market? If so please explain how it was done. I saw on another thread that you can get all the apps to show up via turning on hardware options such as GPS, and touchscreen ...etc. However, I had not luck getting more apps to show up. Also, the link to modaco no longer has the r22 download link.

    ReplyDelete
  29. Same here.
    I somehow managed to set it up once so the market worked.
    But can't reproduce now. Killed a day already. Please help!
    The market is available. When accepted terms/conditions, it crashes. All consequent attempts result in "No matching content in Android Market". HELP!

    ReplyDelete
  30. Mike: for fix out of memory you should reserve memory for system, run with:
    emulator -partition-size 512

    and then make it writeable with:
    adb shell
    mount -o rw,remount -t yaffs2 /system

    ReplyDelete
  31. This is one of the excellent post.This is one of the good quality information.I like your blog technique.
    Android app developers

    ReplyDelete
  32. I did all steps and everythng worked but at final step could not delete cache.img qxx.img - I have double cheked emulator was stoped and .lock files were deleted still file in use kind of thing dint allowed me to continue further...!

    ReplyDelete
  33. This comment has been removed by the author.

    ReplyDelete
  34. This comment has been removed by the author.

    ReplyDelete