95

I selected this emulator from the newest version of Android Studio AVD.

Google API

I have selected the latest version of android API 23. Because it says "with Google APIs", I thought that it would actually include all the Google apps, including Play Store so that I can install apps like Facebook.

I have seen other threads on SO which seems to be outdated now (How to install Google Play app in Android Studio emulator?), this one gives instructions for installing Google apps based on universal packages but it only goes up to Android 4.3 API 18: http://wiki.rootzwiki.com/Google_Apps#Universal_Packages_2

I would like the one for API 23. Is there a way to install the Google Apps package on the emulator?

It seems strange that the official android emulator doesn't come standard with all the google apps in the first place...This doesn't seem very supportive of google and would potential mean developers will have to buy actual devices to develop for API 23?

Community
  • 1
  • 1
Simon
  • 19,658
  • 27
  • 149
  • 217
  • Thanks Ms Yvette. I think its important to get an answer to this question for the android community. There are many android dev out there without access to actual android devices and I wonder how they they are going to dev for android when they are not given access to all the tools. – Simon Dec 18 '15 at 07:40
  • 1
    I don't have enough cred to comment above. Re: the read-only /system partition, make sure you pass the "-writable-system" argument when you call emulator.exe. For example: START /B emulator.exe @Nexus_7-2012_API_22 -no-boot-anim -writable-system – pjl Dec 18 '16 at 04:47
  • @pjl - thank you for this comment! I have added it to my answer. – Dev-iL Dec 20 '16 at 12:39
  • Google says they're working on adding Play Store support to the emulator. Meanwhile, there are a few workarounds you can choose from. Using the Amazon Appstore is one option, but it's not the only option. See [here](http://stackoverflow.com/questions/38593738/is-google-play-store-supported-in-avd-emulators#42520388). – unforgettableidSupportsMonica Feb 28 '17 at 23:07

9 Answers9

58

I've had to do this recently on the API 23 emulator, and followed this guide. It works for API 23 emulator, so you shouldn't have a problem.

Note: All credit goes to the author of the linked blog post (pyoor). I'm just posting it here in case the link breaks for any reason.

....

Download the GAPPS Package

Next we need to pull down the appropriate Google Apps package that matches our Android AVD version. In this case we’ll be using the 'gapps-lp-20141109-signed.zip' package. You can download that file from BasketBuild here.

[pyoor@localhost]$ md5sum gapps-lp-20141109-signed.zip
367ce76d6b7772c92810720b8b0c931e gapps-lp-20141109-signed.zip

In order to install Google Play, we’ll need to push the following 4 APKs to our AVD (located in ./system/priv-app/):

GmsCore.apk, GoogleServicesFramework.apk, GoogleLoginService.apk, Phonesky.apk

[pyoor@localhost]$ unzip -j gapps-lp-20141109-signed.zip \
system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk \
system/priv-app/GoogleLoginService/GoogleLoginService.apk \
system/priv-app/Phonesky/Phonesky.apk \
system/priv-app/GmsCore/GmsCore.apk -d ./

Push APKs to the Emulator

With our APKs extracted, let’s launch our AVD using the following command.

[pyoor@localhost tools]$ ./emulator @<YOUR_DEVICE_NAME> -no-boot-anim

This may take several minutes the first time as the AVD is created. Once started, we need to remount the AVDs system partition as read/write so that we can push our packages onto the device.

[pyoor@localhost]$ cd ~/android-sdk/platform-tools/
[pyoor@localhost platform-tools]$ ./adb remount

Next, push the APKs to our AVD:

[pyoor@localhost platform-tools]$ ./adb push GmsCore.apk /system/priv-app/
[pyoor@localhost platform-tools]$ ./adb push GoogleServicesFramework.apk /system/priv-app/
[pyoor@localhost platform-tools]$ ./adb push GoogleLoginService.apk /system/priv-app/
[pyoor@localhost platform-tools]$ ./adb push Phonesky.apk /system/priv-app

Profit!

And finally, reboot the emualator using the following commands:

[pyoor@localhost platform-tools]$ ./adb shell stop && ./adb shell start

Once the emulator restarts, we should see the Google Play package appear within the menu launcher. After associating a Google account with this AVD we now have a fully working version of Google Play running under our emulator.

nelson2tm
  • 167
  • 8
  • 16
Andy Shephard
  • 1,726
  • 17
  • 26
  • 29
    I receive "ReadOnly file system" error and none of those apk files are installed. – wmac May 13 '16 at 13:43
  • I get permission denied if I try to mount /system/priv-app as read/write – Arina Jun 23 '16 at 08:04
  • running 2 batch file fixed "Read only error" 1) #!/bin/bash d: cd android-sdk-windows/tools/ emulator @devicename -no-boot-anim 2)#!/bin/bash d: cd android-sdk-windows/platform-tools/ adb remount adb push GmsCore /system/priv-app/ adb push GoogleServicesFramework /system/priv-app/ adb push GoogleLoginService /system/priv-app/ adb push Phonesky /system/priv-app adb shell stop && adb shell start pause – saur Jul 01 '16 at 09:08
  • Sorry but where should I run the commands? It won't work via Command Prompt on windows in the adb folder. – Alex Newman Jul 26 '16 at 13:23
  • I still can't push the apks in time before the os starts and mount /system in read-only.. It just push about 80% of PrebuiltGmsCore.apk then fails the upload – Jamby Aug 05 '16 at 10:09
  • 6
    Unfortunately, BasketBuild seems to no longer be available. https://s.basketbuild.com/ indicates it has been down since at least 9/3, with no ETA to be up. Is there another source you recommend for the Google apps? – Chad Schultz Sep 07 '16 at 23:56
  • @Andy Shephard PlayStore gets installed on my emulator, but it does not opens. I am using a x86_64 API 23 System Image of Nexus 5. – ARK Sep 14 '16 at 17:27
  • 1
    If you got "Read-only file system" error, run command: "adb remount". Then try "adb push ..." commands again. – Shangwu Sep 28 '16 at 15:58
  • 4
    All links are dead – Mooing Duck Dec 10 '16 at 02:44
  • 1
    anyone who cant get gapps: http://f.lomakuit.com/download/gapps-lp-20141109-signed.zip – Manny265 Dec 22 '16 at 11:49
  • For those who get the "read only error" you need to temporary change the system folder to r/w permission and remount: http://stackoverflow.com/questions/6066030/read-only-file-system-on-android – equinox93 Dec 24 '16 at 01:25
  • @equinox93 That method will not work on Android 7 due to SELinux. Look at Enyby's answer here (http://stackoverflow.com/questions/5095234/how-to-get-root-access-on-android-emulator#6084432) to see how to start the emulator without SELinux. – jtmaher2 Dec 29 '16 at 03:37
  • 1
    If anybody's having trouble, look at this blog post that explains each step comprehensively (and there a lot): https://infosectrek.wordpress.com/2017/01/17/installing-the-google-play-store-app-apk-on-the-android-emulator/ – Vicky Chijwani Feb 06 '17 at 20:23
  • @VickyChijwani In case you didn't notice, that blog post is based off of [my answer](http://stackoverflow.com/a/38708607/3372061) to this very question.... :) – Dev-iL Mar 01 '17 at 10:06
  • @Dev-iL indeed, I did not notice. The blog post does not link to your answer directly, but to the question as a whole, which is why I missed it. – Vicky Chijwani Mar 01 '17 at 14:13
  • Does anyone get any errors when it comes to the signatures? I can't push my APK files because it keeps giving me a "Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES] error. – LewlSauce Mar 15 '17 at 18:44
  • "read-only" problem can be solved by launching emulator with "-writable-system" parameter: `emulator @ -no-boot-anim -writable-system` – tdd Mar 28 '19 at 08:48
  • @wmac try to run `adb root` before running adb push – Jek May 13 '20 at 19:58
53

Below is the method that worked for me on API 23-25 emulators. The explanation is provided for API 24 but works almost identically for other versions.

Credits: Jon Doe, zaidorx, pjl.

Warm advice for readers: please just go over the steps before following them, as some are automated via provided scripts.


  1. In the AVD manager of Android studio (tested on v2.2.3), create a new emulator with the "Android 7.0 (Google APIs)" target: AVD screen after creating the emulator.

  2. Download the latest Open GApps package for the emulator's architecture (CPU/ABI). In my case it was x86_64, but it can be something else depending on your choice of image during the device creation wizard. Interestingly, the architecture seems more important than the correct Android version (i.e. gapps for 6.0 also work on a 7.0 emulator).

  3. Extract the .apk files using from the following paths (relative to open_gapps-x86_64-7.0-pico-201#####.zip):

    .zip\Core\gmscore-x86_64.tar.lz\gmscore-x86_64\nodpi\priv-app\PrebuiltGmsCore\
    .zip\Core\gsfcore-all.tar.lz\gsfcore-all\nodpi\priv-app\GoogleServicesFramework\
    .zip\Core\gsflogin-all.tar.lz\gsflogin-all\nodpi\priv-app\GoogleLoginService\
    .zip\Core\vending-all.tar.lz\vending-all\nodpi\priv-app\Phonesky\
    

    Note that Open GApps use the Lzip compression, which can be opened using either the tool found on the Lzip website1,2, or on Mac using homebrew: brew install lzip. Then e.g. lzip -d gmscore-x86_64.tar.lz.

    I'm providing a batch file that utilizes 7z.exe and lzip.exe to extract all required .apks automatically (on Windows):

    @echo off
    echo.
    echo #################################
    echo Extracting Gapps...
    echo #################################
    7z x -y open_gapps-*.zip -oGAPPS
    
    echo Extracting Lzips...
    lzip -d GAPPS\Core\gmscore-x86_64.tar.lz
    lzip -d GAPPS\Core\gsfcore-all.tar.lz
    lzip -d GAPPS\Core\gsflogin-all.tar.lz
    lzip -d GAPPS\Core\vending-all.tar.lz
    
    move GAPPS\Core\*.tar
    
    echo. 
    echo #################################
    echo Extracting tars...
    echo #################################
    
    7z e -y -r *.tar *.apk
    
    echo.
    echo #################################
    echo Cleaning up...
    echo #################################
    rmdir /S /Q GAPPS
    del *.tar
    
    echo.
    echo #################################
    echo All done! Press any key to close.
    echo #################################
    pause>nul
    

    To use this, save the script in a file (e.g. unzip_gapps.bat) and put everything relevant in one folder, as demonstrated below: What it should look like...

  4. Update the su binary to be able to modify the permissions of the files we will later upload. A new su binary can be found in the SuperSU by Chainfire package "Recovery flashable" zip. Get the zip, extract it somewhere, create the a batch file with the following contents in the same folder, and finally run it:

    adb root
    adb remount
    
    adb push eu.chainfire.supersu_2.78.apk /system/app/
    adb push x64/su /system/xbin/su
    adb shell chmod 755 /system/xbin/su
    
    adb shell ln -s /system/xbin/su /system/bin/su
    adb shell "su --daemon &"
    adb shell rm /system/app/SdkSetup.apk
    
  5. Put all .apk files in one folder and create a batch file with these contents3:

    START /B E:\...\android-sdk\tools\emulator.exe @Nexus_6_API_24 -no-boot-anim -writable-system
    adb wait-for-device
    adb root
    adb shell stop
    adb remount
    adb push PrebuiltGmsCore.apk /system/priv-app/PrebuiltGmsCore
    adb push GoogleServicesFramework.apk /system/priv-app/GoogleServicesFramework
    adb push GoogleLoginService.apk /system/priv-app/GoogleLoginService
    adb push Phonesky.apk /system/priv-app/Phonesky/Phonesky.apk
    adb shell su root "chmod 777 /system/priv-app/**"
    adb shell su root "chmod 777 /system/priv-app/PrebuiltGmsCore/*"
    adb shell su root "chmod 777 /system/priv-app/GoogleServicesFramework/*"
    adb shell su root "chmod 777 /system/priv-app/GoogleLoginService/*"
    adb shell su root "chmod 777 /system/priv-app/Phonesky/*"
    adb shell start
    

    Notice that the path E:\...\android-sdk\tools\emulator.exe should be modified according to the location of the Android SDK on your system.

  6. Execute the above batch file (the console should look like this afterwards):

    O:\123>START /B E:\...\android-sdk\tools\emulator.exe @Nexus_6_API_24 -no-boot-anim -writable-system
    
    O:\123>adb wait-for-device
    Hax is enabled
    Hax ram_size 0x60000000
    HAX is working and emulator runs in fast virt mode.
    emulator: Listening for console connections on port: 5554
    emulator: Serial number of this emulator (for ADB): emulator-5554
    
    O:\123>adb root
    
    O:\123>adb shell stop
    
    O:\123>adb remount
    remount succeeded
    
    O:\123>adb push PrebuiltGmsCore.apk /system/priv-app/PrebuiltGmsCore/
    [100%] /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk
    
    O:\123>adb push GoogleServicesFramework.apk /system/priv-app/GoogleServicesFramework/
    [100%] /system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk
    
    O:\123>adb push GoogleLoginService.apk /system/priv-app/GoogleLoginService/
    [100%] /system/priv-app/GoogleLoginService/GoogleLoginService.apk
    
    O:\123>adb push Phonesky.apk /system/priv-app/Phonesky/Phonesky.apk
    [100%] /system/priv-app/Phonesky/Phonesky.apk
    
    O:\123>adb shell su root "chmod 777 /system/priv-app/**"
    
    O:\123>adb shell su root "chmod 777 /system/priv-app/PrebuiltGmsCore/*"
    
    O:\123>adb shell su root "chmod 777 /system/priv-app/GoogleServicesFramework/*"
    
    O:\123>adb shell su root "chmod 777 /system/priv-app/GoogleLoginService/*"
    
    O:\123>adb shell su root "chmod 777 /system/priv-app/Phonesky/*"
    
    O:\123>adb shell start
    
  7. When the emulator loads - close it, delete the Virtual Device and then create another one using the same system image. This fixes the unresponsive Play Store app, "Google Play Services has stopped" and similar problems. It works because in the earlier steps we have actually modified the system image itself (take a look at the Date modified on android-sdk\system-images\android-24\google_apis\x86_64\system.img). This means that every device created from now on with the system image will have gapps installed!

  8. Start the new AVD. If it takes unusually long to load, close it and instead start it using:

    START /B E:\...\android-sdk\tools\emulator.exe @Nexus_6_API_24
    adb wait-for-device
    adb shell "su --daemon &"
    

    After the AVD starts you will see the image below - notice the Play Store icon in the corner!

First boot with Play Store installed.


3 - I'm not sure all of these commands are needed, and perhaps some of them are overkill... it seems to work - which is what counts. :)

Community
  • 1
  • 1
Dev-iL
  • 23,742
  • 7
  • 57
  • 99
  • 2
    Instead of .xz files, Open Gapps seems to contain .lz files (like gsfcore-all.tar.lz). I've tried multiple tools, none of which are able to decompress the .lz files so I can get at the APKs. Any suggestions? – Chad Schultz Sep 08 '16 at 00:40
  • I use WinRAR.. Which type of gapps (architecture and version) are you trying to use? – Dev-iL Sep 08 '16 at 00:45
  • 2
    @Chad Schultz here's the link for the tool http://download.savannah.gnu.org/releases/lzip/ if youre on windows download "lzip-1.11-w32.zip" and use the following command to convert it to a .tar file and use another tool to finally extract it. – f4b Sep 08 '16 at 08:24
  • @Dev-iL For example, x86 for 5.1 or x86_64 for 6.0 both contain .lz files. I am using a Mac. – Chad Schultz Sep 09 '16 at 18:26
  • @ChadSchultz I see what you mean. This is a recent change in OpenGapps (at the time of answer writing, the files contained `.xz` archives). In any case, the following method worked for me on Mac: 1) `brew install lzip` 2) `$ lzip -d gmscore-x86_64.tar.lz` 3) . I tried python's `patool` and `pyunpack` but they seem to still require the correct executables to be present on the machine. I hope this helps... – Dev-iL Sep 10 '16 at 14:51
  • this method doesn't work on latest android N emulator. after whole steps emulator has been started and google services has been crashed. no 'play market' app in the app list – deviant Sep 12 '16 at 14:07
  • @deviant Thank you for the report. If you manage to resolve it, please come back and say how. For now - could you try it with [the latest `apk` from here](http://forum.xda-developers.com/showthread.php?t=1996995) instead of the `Phonesky.apk` that comes in the GApps collection? – Dev-iL Sep 12 '16 at 14:22
  • @Dev-iL that does work for unpacking the files when all the graphical tools failed! Thanks! – Chad Schultz Sep 12 '16 at 15:12
  • 1
    @Dev-iL PlayStore gets installed on my emulator, but it does not opens. I am using a x86_64 API 23 System Image of Nexus 5. Any thoughts? – ARK Sep 14 '16 at 17:28
  • @akshayrajkore It can be anything.. You can try writing a question about this.. Perhaps post a piece of logcat or some screenshots... Are you using the image with the Google APIs or the "clean" one? – Dev-iL Sep 14 '16 at 17:32
  • @akshay this method is for the other type of images..You could try that type, but I can't promise it will help. It's really a matter of trial and error.... – Dev-iL Sep 14 '16 at 18:00
  • I had created an x86_64 Google APIs Nougat ADV and did everything successfully. But the Play Store closed when I started it, as others said. I deleted the AVD and created another with the same image. Play Store was there right from the start, and I could now run it. I could install some apps such as Opera, but I could not quite a few apps such as Firefox. "Your device isn't compatible with this version" was displayed. – Damn Vegetables Sep 28 '16 at 16:34
  • i just have followed above steps to install gapps for my android studio 2.2 avd without error, but in emulator, there is a pop up message said "Google play services keeps stopping", anyone know how to fix it? – hkguile Oct 12 '16 at 09:23
  • @hkguile The crashes are caused by missing permissions for the Google apps, because they weren't installed properly as system apps. (If you open logcat and look for errors you will see things like `java.lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.`). I don't know what exactly I did to make it work, but I can tell you that when it works, your "Google APIs ... System Image" shows as corrupted in the SDK manager list - this is ok. I will try to retrace my steps and update the answer when I find the solution. One can still use the Play Store though... – Dev-iL Oct 15 '16 at 15:30
  • 3
    This worked for me on the latest 25/7.1 emulator. The only thing that was odd was that `/system/app/SdkSetup.apk` didn't exist in my image. Thanks a lot, was going crazy trying to work this out! – wilsonpage Nov 11 '16 at 12:23
  • 1
    How do you exactly "create another one using the same system image"? – gavsiu Feb 14 '17 at 19:57
  • 1
    @gavsiu I meant you just create a new AVD, and when presented with the choice of a device, choose the same device as you had when you were doing the previous steps. Is it clear? – Dev-iL Feb 14 '17 at 20:03
  • Thanks. I didn't realize it modified the actual system image downloaded by the SDK. – gavsiu Feb 14 '17 at 20:34
  • So I've been experimenting with getting Play Store to work. On 7.1.1, a lot of apps say the device is incompatible. I suspect it's because the only architectures available on the SDK are Intel Atom 32/64 bit. Firefox apk from their website (the only one) is for ARM. Side note: Sdksetup was not removed. On 7.0 ARM64, Sdksetup is required to be removed and found in /system/priv-app/Sdksetup. After recreating the AVD, there are no errors. However, Play Store refuses to open and in Settings>Accounts, Google is not an option. – gavsiu Feb 16 '17 at 04:22
  • How are you all even getting those APK files to display? After using LZIP on those 4 tar.lz files, and then using 7z to extract just APK files as mentioned in this instruction, the only APK file that appears is PrebuiltGmsCore.apk – LewlSauce Mar 15 '17 at 15:43
  • @LewlSauce I don't really understand which step you're having a problem with. You might want to post that as a separate question. There, you would have a chance to show us what you did and where you got stuck. Feel free to link to it from here afterwards. If the script failed for you, did you try to extract the files manually? – Dev-iL Mar 21 '17 at 09:17
  • 1
    @Dev-iL Thanks man. I gave up. I couldn't push the APK files because of signature errors. – LewlSauce Mar 21 '17 at 14:25
  • Strings like `adb shell su root "chmod 777 /system/priv-app/PrebuiltGmsCore/*"` are wrong, because they write: `su: failed to exec chmod 777 /system/priv-app/PrebuiltGmsCore/: No such file or directory`. – CoolMind Jan 02 '19 at 15:47
  • I've tried all references I could find but keep getting stuck at `adb remount1` I keep on getting error: */system/bin/remount exited with status 7 remount failed* – MariusB Jun 03 '20 at 13:52
  • @MariusB Are you using the exact same versions of all tools mentioned in this post? If not, I would start there. – Dev-iL Jun 05 '20 at 10:27
  • Is there any solution for API 26? Because there is no `gsflogin-all.tar.lz` there – HendraWD Feb 17 '21 at 17:27
43

Now there's no need to side load any packages of execute any scripts to get the Play Store on the emulator. Starting from Android Studio 2.4 now you can create an AVD that has Play Store pre-installed on it. Currently it is supported only on the AVDs running Android 7.0 (API 24) system images.

Official Source

AVD with Play Store

Note: Compatible devices are denoted by the new Play Store column.

Prerak Sola
  • 9,517
  • 7
  • 36
  • 67
  • 8
    Note: you need to install a system image that says Target: `Android 7.0 (Google Play)`, not just Google APIs. Currently it's only available for API 24, not API 25. Once you install the system image it will appear under the Recommended tab, not the x86 Images tab. – antoine May 30 '17 at 00:46
  • 2
    Android Studio 2.3.3 on Linux now supports Play Store AVDs - but it's also worth noting that the Play Store only seems to be available on x86 targets at present, so you'll still need to use another method if you want to get the Play Store on an ARM AVD. – NullColaShip Jul 23 '17 at 03:47
  • There are now also images for APIs 25, 26 and 27 in addition to 24. – arekolek Nov 17 '17 at 00:19
29

Wanted to comment on the last answer, but without login it’s only possible to make an answer:

To get rid of the "read only error" just stop the device immediately after it’s ready. My script looks as follows:

#!/bin/bash 
~/bin/AndroidSdk/tools/emulator @Nexus_6P_API_23 -no-boot-anim &
adb wait-for-device
adb shell stop
adb remount
adb push GmsCore.apk /system/priv-app
adb push GoogleServicesFramework.apk /system/priv-app
adb push GoogleLoginService.apk /system/priv-app
adb push Phonesky.apk /system/priv-app
adb shell start
Jon Doe
  • 291
  • 3
  • 2
  • 1
    This one help me solve the read-only file system error. since I am working in windows, I just ignored the first line of the script and replace the second one with this "START /B /tools/emulator @Nexus_6P_API_23 -no-boot-anim", saved it with .bat extension and run it from the command line. – zaidorx Jul 14 '16 at 18:33
  • put adb root at the beggining if you have adb shell stop stop: must be root error. – nutella_eater Nov 29 '16 at 19:56
  • `adb root` line should be added immediately after `adb wait-for-device` line to prevent `Read-only file system` error. – efkan Dec 08 '16 at 08:50
  • 2
    This worked once I added -writable-system to my emulator command like this, ~/android-sdk/tools/emulator @Nexus_5X_API_23 -no-boot-anim -writable-system – reassembler Feb 22 '17 at 18:45
7

Solved in easy way: You should create a new emulator, before opening it for the first time follow these 3 easy steps:

1- go to "C:\Users[user].android\avd[your virtual device folder]" open "config.ini" with text editor like notepad

2- change

"PlayStore.enabled=false" to "PlayStore.enabled=true"

3- change

"mage.sysdir.1 = system-images\android-30\google_apis\x86"

to

"image.sysdir.1 = system-images\android-30\google_apis_playstore\x86"

Sharif Yazdian
  • 4,332
  • 3
  • 20
  • 22
4

Here's the script i used on linux for an instance Nexus 5 API 24 x86 WITHOUT GoogleApis.

#!/bin/sh

~/Android/Sdk/tools/emulator @A24x86 -no-boot-anim -writable-system & #where A24x86 is the name i gave to my instance
~/Android/Sdk/platform-tools/adb wait-for-device
~/Android/Sdk/platform-tools/adb root
~/Android/Sdk/platform-tools/adb shell stop
~/Android/Sdk/platform-tools/adb remount
~/Android/Sdk/platform-tools/adb push ~/gapps/PrebuiltGmsCore.apk /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk
~/Android/Sdk/platform-tools/adb push ~/gapps/GoogleServicesFramework.apk /system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk
~/Android/Sdk/platform-tools/adb push ~/gapps/GoogleLoginService.apk /system/priv-app/GoogleLoginService/GoogleLoginService.apk
~/Android/Sdk/platform-tools/adb push ~/gapps/Phonesky.apk /system/priv-app/Phonesky/Phonesky.apk
~/Android/Sdk/platform-tools/adb shell "chmod 777 /system/priv-app/PrebuiltGmsCore /system/priv-app/GoogleServicesFramework"
~/Android/Sdk/platform-tools/adb shell "chmod 777 /system/priv-app/GoogleLoginService /system/priv-app/Phonesky"
~/Android/Sdk/platform-tools/adb shell "chmod 777 /system/priv-app/PrebuiltGmsCore/PrebuiltGmsCore.apk"
~/Android/Sdk/platform-tools/adb shell "chmod 777 /system/priv-app/GoogleServicesFramework/GoogleServicesFramework.apk"
~/Android/Sdk/platform-tools/adb shell "chmod 777 /system/priv-app/GoogleLoginService/GoogleLoginService.apk"
~/Android/Sdk/platform-tools/adb shell "chmod 777 /system/priv-app/Phonesky/Phonesky.apk"
~/Android/Sdk/platform-tools/adb shell start

This one did it for me.

IMPORTANT: in order to stop the app from crashing remember to grant google play services location permissions.

Configuration->Apps->Config(Gear icon)->App permissions->Location->(Top right menú)->Show system->Enable Google Play services

Richard
  • 719
  • 10
  • 11
4

What you need to do is update the config.ini file for the device and re-download the system image.

Update the following values in the .ini file

  • Windows: C:\Users\USER\.android\avd\DEVICE_ID\config.ini
  • Linux: ~/.android/avd/DEVICE_ID/config.ini
PlayStore.enabled = true
image.sysdir.1=system-images\android-27\google_apis_playstore\x86\
tag.display=Google Play
tag.id=google_apis_playstore

Then re-download the system image for the device from Android Studio > Tools > AVD Manager

That is all. Restart your device and you'll have the Play Store installed.

This has also been answered here: How to install Google Play app in Android Studio emulator?

Aamnah
  • 559
  • 6
  • 9
  • When I touch on download I get this error "All packages are not available for download !, The following packages are not available: - Package id system-images; android-23; google_apis_playstore; x86" – JP711 Jun 20 '21 at 14:01
2

Go to http://opengapps.org/ and download the pico version of your platform and android version. Unzip the downloaded folder to get
1. GmsCore.apk
2. GoogleServicesFramework.apk
3. GoogleLoginService.apk
4. Phonesky.apk

Then, locate your emulator.exe. You will probably find it in
C:\Users\<YOUR_USER_NAME>\AppData\Local\Android\sdk\tools

Run the command:
emulator -avd <YOUR_EMULATOR'S_NAME> -netdelay none -netspeed full -no-boot-anim -writable-system

Note: Use -writable-system to start your emulator with writable system image.

Then,
adb root
adb remount
adb push <PATH_TO GmsCore.apk> /system/priv-app
adb push <PATH_TO GoogleServicesFramework.apk> /system/priv-app
adb push <PATH_TO GoogleLoginService.apk> /system/priv-app
adb push <PATH_TO Phonesky.apk> /system/priv-app

Then, reboot the emulator
adb shell stop
adb shell start

To verify run,
adb shell pm list packages and you will find com.google.android.gms package for google

Saini Arun
  • 391
  • 3
  • 7
1

As of now, Installing the apks to the /system directory seems to be working using adb push command.

Some hidden service was automatically remounting the /system directory in read-only mode.

Any way I was able to install the Play store in a normal virtual-machine ( Ie, non-Google-Api virtual machine ) by simply mounting the system.img file from my OS and by copying over the files.

# To be executed as root user in your Unix based OS
mkdir sys_temp
mount $SDK_HOME/system-images/android-23/default/x86/system.img sys_temp -o loop
cp Phonesky.apk GmsCore.apk GoogleLoginService.apk GoogleServicesFramework.apk ./sys_temp/priv-app/
umount sys_temp
rmdir sys_temp

The APK files can be pulled from any real Android device running Google Apps by using adb pull command

[ To get the exact path of the apks, we can use command pm list packages -f inside the adb shell ]

AL.
  • 36,815
  • 10
  • 142
  • 281
harish2704
  • 591
  • 6
  • 16
  • 2
    I've installed linux and copy apks to a 6.0 system.img with google apis, but when i created a new emulator, it didnt have google play service or google play store. I will try again with non google apis rom. – noname.cs Sep 09 '16 at 01:52