Archive

This has been tested on the Android Emulator that comes default installed with the Android SDK with Android Studio 2.2.3.

The Android OS version used was the latest Android 7.1.1 (Nougat) and the Google Play APK version was 10.0.84 from OpenGapps (although I think any latest versions of the APK should work).

The basic idea from this post was adapted from a StackOverflow post [1] that had good ideas, but I had to tweak them to get it to work for my case.

TL;DR: The basic idea is that you need to get the APK files put them in the right location of the system partition (after getting it to be writable). Then giving the APK’s the right permisions (I gave them all 777, i don’t know why, i just wanted it to work, but perhaps not so good for security. May be 755 will also work.). Then reboot, once rebooted shutdown the instance, delete the Emulator instance from the Android Virtual Device manager, and clone another image out of the one that was written to. (If you didn’t get that … all the details are below…)

Intro:

To get just the Google Play APK and it’s related services select the Pico version from the OpenGapps website. If you want other Google Apps also e.g. Gmail, Google Now, Google Music, Calendar, Youtube, etc you’ll have to select one of the other OpenGapps packages that has the apps you want.

Getting the APKs out of the OpenGapps ZIP (and TAR.LZ) archive

For this part you’ll need something that can open ZIP files and decompress the LZIP format. On Windows i used 7Zip and Lzip

I used the Windows batch script below found at the StackOverflow question cited[1] and created a batch file called unzip_gapps.bat. Make sure to change the line lzip -d GAPPS\Core\gmscore-x86_64.tar.lz to the file for which ever version of architecture you’re using, in my case it was x86 instead of x86_64

Put all the files (open_gapps-*.zip, 7z.exe, lzip.exe, unzip_gapps.bat) into a single directory and run the batch file.

The APK files should now be extracted and “automagically” appear in the directory.

Putting the APK’s in the right place on the Android device

NB: This needs some form of getting the /system partition (directory) to be writable, or to have root access in order to make the /System partition writable. I’ve seen some form of attempt at rooting the emulator here, in order to make the /system partition writable, but this didn’t do the trick for me.

Assuming that you have Android Studio, the SDK and an Emulator instance created with Android 7.1.1 (API 25), I had to start the emulator from the CLI with the directive writable-system

Windows:

emulator.exe -avd <Emulator_Instance_Name> -writable-system

Ubuntu:

./emulator -avd <Emulator_Instance_Name> -writable-system

Now the APK’s need to be put into the /system/priv-app/ directory, inside directories, each with the specific name of the APK it contains. You’ll probably need root privileges to write to the system/priv-app directory. I used adb root to grant me root access. For some reason I also needed to to adb remount to make sure that the /system partition becomes writable (Not sure why, if i already asked the emulator to have a writable /system partition, but this had to be done). For subsequent accesses you can also get into the shell using adb shell and then from there switch user to root with su root.

NB: You might already have the directories PrebuiltGmsCore, GoogleServicesFramework, GoogleLoginService. (Unlikely you’ll have Phonesky). But create whichever ones you need as seen below.

Now you’ll need root access again to change the APK permissions. As mentioned earlier, i gave the permissions 777 to the files, but i’m not sure whether such high permissions are needed for all users, i think 755 might be more appropriate, but i haven’t tested this.

At this point the APK’s might start installing themselves and you might get an error saying the Play Services have stopped or com.google.Gmscore has stopped, or something close to that. Ignore it.

[Before April 2017, the rest of this guide was relevant, from April 2017, you don’t need to do the rest. Restarting the emulator should work.]

Restarting and Creating another Image

(For Emulator versions, below v25, that is: Before April 2017)

Restart the Emulator and even now you’ll probably still be getting the Play Services have stopped or com.google.Gmscore has stopped or something close to that.

Now shutdown the emulator normally, using the power button long-press.

After it has shutdown, go to the Android Virtual Device (AVD) manager through Android Studio (Tools > Android > AVD Manager). Delete the Virtual Device Instance and create a new one (this sounds counter intuitive, but if you check the time-stamps of the system image where these devices are cloned from [ {android_version_home_dir}/sdk/system-images/{android-version-number}/system.img> ] you’ll notice that the system was written to pretty recently). This is because we had the writable-system directive when we were making the changes, thus the Play Store APK got installed to /system partition “permanently”, so any new AVD created for this particular version of Android, it will have the Google Play Store APK installed properly.

Create a new AVD from the modified system-image android version and you’ll see the Play Store App installed, ready and waiting on the home screen.