Sunday, November 21, 2010

[How to] Install Android market on Emulator

Android Emulator is a virtual mobile that is packaged along with the Android SDK. It runs on your computer and can be used to prototype, develop and test applications without having to buy a physical device. Almost all of the hardware and software features of a typical mobile device are mimicked in the Android emulator. However, if you want to try out some apps from the Android market, you can’t do that with the emulator as it does not include ‘Android market’. Here is a step-by-step guide to enable Android market in the emulator.
Steps to enable Android market in the emulator
1. Download and install the latest Android SDK (Android 2.2, API 8, revision 2) from here. This comes up with all the tools needed for development and testing of your application. Make sure the driver ‘ADB interface’ is installed on your machine. In most of the cases, the driver will be installed directly once you plug-in the device. [The SDK installation location will be referred to as SDK_LOCATION in the rest of the article]
Android SDK Setup2. Next step is to create a Android Virtual Device. Select ‘Virtual Devices’ from the left pane of the Android SDK and AVD Manager. Create a new virtual device with the details mentioned in the screenshot below. The screen might be frozen for few minutes while the virtual device is being created. Android Virtual DevicesAndroid Virtual Device3. After the device is created, go to the location ‘%userprofile%/.android/avd’. You will find a folder named ‘DemoDevice.avd’. Copy the system image ‘system,img’ from ‘SDK_LOCATION/platforms/android-8/images’ to the folder 'DemoDevices.avd’.
4. Start the emulator specifying the partition size. From cmd: emulator –avd DemoDevice –partition-size 100. (100 MB will be allotted for user space). Emulator opens up and it looks like the one below. Note: If the command emulator is not recognized, add SDK_LOCATION/tools to the PATH variable.
Android Emulator 5. From cmd, execute ‘adb pull /system/build.prop .’. This will copy the file build.prop to your current working directory. Open it with your favorite text editor and change the property ‘ro.config.nocheckin=yes’. This is needed to fix the freezing of market downloads. Related article.
6. Now, we have to push back the modified build.prop. This is not as easy as pulling it out. First, you have to mount the /system partition in read-write mode. Check out this to know how to do that. After the partition is remounted, execute the adb push command to push back the build.prop ‘adb push build.prop /system/.
7. The next thing is to install the Market application. Download ‘Vending.apk’ from this thread. Google Services framework is a pre-requisite for Android market. To get ‘GoogleServicesFramework.apk’, download upload.zip from here and extract the zip to find the .apk file inside /system/app. Download 'GoogleServcesFramework.apk' from here. Push both these .apk to the device. ‘adb push Vending.apk /system/app/.’ ‘adb push GoogleServicesFramework.apk /system/app/.’. Also, delete the  SdkSetup.apk from the device. ‘adb shell rm /system/app/SdkSetup.apk’. Make sure the SdkSetup.apk is deleted otherwise the emulator will be reverted back to its original stage.
8. Close the emulator. Delete the images userdata.img, userdata-qemu.img and cache.img from ‘%userprofile%/.android/avd/DemoDevice.avd’. Start the emulator again from Android SDK and AVD Manager. Android Market will be available on the emulator now. On opening the market, you will be prompted to connect with your Google account. Connect with your Google account and install your favorite apps on the emulator.
Android emulator with Android MarketConnecting to Android market with Google AccountAndroid Market Terms of ServiceTop free games on Android marketSolitaire installed from Android Market
Note: Installation of apps from Android market seems to be very slow in the emulator. Market app crashed couple of times before I get the chance to install the apps. Also, I could not find the most popular Android game ‘Angry Birds’ in the market. Installing the same from its .apk didn’t work either. I am trying to tweak the emulator to make it work smoothly with Android Market. If you have any tips for the same, please post them as comments here.
Update: Uttam Hoode has tried this approach with Android 2.3 SDK and it worked fine.
-- Varun

No comments:

Post a Comment

google-site-verification: googlea4d68ed16ed2eea6.html