How to install Google Play Services on an Android Emulator the easy way.

Hitesh Bisht
5 min readAug 12, 2018

We all have come across more than one reason to install Google’s “Play Store” app on our android virtual devices(AVD). In fact, starting with Android studio 2.3.2 now we get an option to create an AVD that has pre-installed “Play Store” application.
But before we start celebrating thinking that we will be able to use “Play Store” on all hardware and API configurations, there is a catch!

Pre-installed “Play Store” application is only supported for below use cases only:
· The device hardware configuration should be Nexus 5 or 5X only and API level should be above 24 (Android 7.0).
· wear OS.

You can see play store icon for supported devices only. There is no support for tablets yet (Aug-2018).

But what if we want to test some other screen sizes, tablets, API level below 24, different hardware profile, etc. Well, in that case, we will have to look the other way and I shall explain the process in the easiest way.

Install and configure 7zip:
7zip is a free open source tool for unarchiving. Download from here (https://7-zip.org) and install.

Now go the installed location of 7zip software.

The default location is

“C:\Program Files\7-Zip” for 64-bit windows machines and

“C:\Program Files (x86)\7-Zip” for 32bit machines.

Create a new sub-folder named “Formats” inside “7zip” folder. It should look like this

Now we need to download “LZip” plugin which is required to extract files with “lz” extension. Don’t worry you will understand just be patient :) . Download the plugin from here http://tc4shell.com/en/7zip/lzip/.
After the download is complete extract the “LZip.zip” file. You will find these files after extraction.

Depending upon the variant of 7zip you installed x86(32 bit) or x64(64 bit) you need to copy one, either “Lzip.32.dll” or “Lzip.64.dll” and also copy the “lzip.ini” file and paste it inside the “Formats” folder we just created. This is how the “Formats” folder will look for windows 64-bit machines.

Now we need to install the Google GApps package. This contains all the essential Google apps that are required for “Play Store” to work. To download click here https://opengapps.org. You will be redirected to website where you will need to fill in the configuration before download. Please follow the below configurations:

· Platform: x86

· Android: 7.0 (don’t download 7.1 and above as of now they don’t have the “GoogleLoginService.apk” that is required for “Play Store” to work.)

· Variant: You can choose any variant but for minimal apps, I would recommend going with “pico”.

Once the Gapps is downloaded, extract it with 7zip. In the extracted files open the folder “Core” > inside it you will see “vending-x86.tar.lz”.

Here comes the part for which we configured 7zip with Lzip plugin. Use 7zip to extract the file and then you will get another file with “tar” extension, extract that also with 7zip. Then go into below mentioned directory.

From here copy the “Phonesky.apk” and place it on your desktop for now. Similarly, extract “gsflogin-all.tar” file and copy the “GoogleLoginService.apk” to desktop.(For location see image below).

Now go to the android studio AVD and create any virtual device with API level 24 (7.0). It should be equivalent to the Gapps we downloaded.
Give an easy name to a virtual device like “Pixel2” as you will need to type it in command prompt :P.

We have to go to the location where Android SDK is installed. It should be something like this for windows user.
C:\Users\YOUR_USER_NAME\AppData\Local\Android\Sdk\tools
we have to start command prompt and run the following command

cd C:\Users\YOUR_USER_NAME\AppData\Local\Android\Sdk\tools

Then we start the AVD we created using command prompt because we want to run the emulator in writable mode. Do not start the virtual device from AVD UI, use the command mentioned below. If you get any error make sure android emulator is installed in the android studio by checking in SDK manager> SDK tools.

Now type the below command:

emulator @Pixel2 -writable-system

This should start the virtual device. Don’t close this command prompt window and start another command prompt instance. We need to run ADB using it. The location of ADB will be something like:
“C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools”

In the new command prompt instance, we run below commands to access ADB shell with root permission:

cd C:\Users\hitec\AppData\Local\Android\Sdk\platform-tools
ADB shell
su

Your screen should look like this post running the above commands

By default, the file system is read-only so now we have to make it writable. Run below command

cat /proc/mounts |grep system

We have to write the red marked area in the screenshot above and type below command

mount -o rw,remount /dev/block/vda /system

To verify that the file system is writable, we have to run below command again and you will see “rw”(read-write) instead of “ro”(read-only)

cat /proc/mounts |grep system

Now copy the Phonesky.apk” and “GoogleLoginService.apk” that we kept on the desktop to “platform-tools” folder where adb is located. We are pasting these APKs here to make commands look simpler. We can delete them once we push them to our emulator.
Now in the Command prompt press “Ctrl +D” twice to exit the ADB shell.

Now the final part to push APKs :)
Enter the following commands

ADB root
adb push Phonesky.apk /system/priv-app/
adb push GoogleLoginService.apk /system/priv-app/

Now we just need to stop and start ADB with below commands and it’s done.

ADB shell stop
ADB shell start

This should restart the emulator and now you should see the Play Store application on AVD.

· Or wear OS.

--

--