45

I'm using the new VS Android Emulator with Android Studio:

https://www.visualstudio.com/en-us/features/msft-android-emulator-vs.aspx

It doesn't have Google Play Services installed... so I'm following this guide to install:

https://university.xamarin.com/resources/how-to-install-google-play-on-android-emulator

I've downloaded the proper Gapps file (in my case):

http://www.devfiles.co/download/7m2VdVjQ/gapps-kk-20140105-signed.zip

Now I've dragged and dropped the ZIP file onto the emulator... and it's just stalled at "copying file"... Is there anything else I need to be doing here in order to get Gapps installed? How long does this "install" usually take?

enter image description here

aherrick
  • 19,799
  • 33
  • 112
  • 188
  • Possibly related: https://stackoverflow.com/questions/28757003/how-to-install-google-play-app-in-android-studio-emulator and https://stackoverflow.com/questions/34291902/android-studio-emulator-does-not-come-with-play-store-for-api-23?noredirect=1&lq=1 – That Brazilian Guy Nov 11 '17 at 17:08
  • Anyone using the VS2017 emulator for android, have a look at: https://alteridem.net/2017/02/02/installing-google-play-gapps-visual-studio-android-emulators/ – Jonty Aug 03 '20 at 15:17

10 Answers10

70

I was trying it out yesterday myself and had the same problem. Apparently, non of the drag and drop functionality worked. So this, is what I did to resolve the issue:

  1. Use the Additional Tools (small >> icon) for the emulator and go to the SD Card tab.
  2. Select a folder on your computer to sync with the virtual SD card.
  3. Pull from SD card, which will create a folder structure on the selected folder.
  4. Now copy the Gapps fill to the 'Download' folder.
  5. Push to SD card. This will take a little while, and copy the zip file to your emulator.
  6. Run a commmand prompt, and go to sdk\platform-tools in your Android SDK location and run adb devices.
  7. If you see the your emulator in the list, then skip to step 9.
  8. If you do not see emulator, run the following: adb connect <emulator ip>:5555 You can find the emulator ip, from within the emulator, go to Settings -> About Phone -> Status and IP section.
  9. Next run, adb shell. This will give you a prompt to the android emulator.
  10. Confirm the gapps file is there: ls /sdcard/Download
  11. Now run, install_zip.sh /sdcard/Download/<flashablezip>.zip This should begin the flashing process.

Hope this helps in resolving the issue.

Endareth
  • 492
  • 3
  • 15
Vijay S
  • 834
  • 7
  • 3
  • 2
    What if you do not have a Download folder but only a `0`, `legacy` and `obb` folder in the sd card folder? (step 4) – JP Hellemons Sep 23 '15 at 08:28
  • 2
    Rather than the push / pull steps, you could also run "adb push c:\whatever\full_file_name.zip /sdcard/Downlad/gapps.zip" – Scott R. Frost Feb 15 '16 at 15:10
  • Thanks for the great info, but when I try to login to play store or add an account, I got an error: "Couldn't sign in: There was a problem communicating with Google servers. Try again later." – Owidat Aug 08 '16 at 11:14
  • 3
    You can actually skip steps 6 - 9 by using HyperV to shell into the device. Then - su root; cd /sdcard/Download; install_zip.sh – mitchellJ Nov 10 '16 at 04:01
  • 4
    What to do with `Installing file '/system/*' cp: /data/local/tmp/.flash_tmp/system/*: No such file or directory cp: bad '/data/local/tmp/.flash_tmp/system/*': No such file or directory Could not copy '/data/local/tmp/.flash_tmp/system/*' to '/system/*'` – Andrii Dec 29 '16 at 23:00
  • If the drag/drop isn't working, ensure you are NOT starting the emulator from an elevated (ie administrator) role. – Steven Pena Jan 24 '17 at 23:43
  • @Andrii The 'could not copy' error indicates an incorrect Gapps file for your emulator. – Chris Schiffhauer Feb 21 '17 at 20:42
  • 1
    The Gapps posted http://opengapps.org/ are not installable as they don't include `system` folder – Andrii Feb 22 '17 at 22:18
  • 1
    If you do have folder named "0" put Download folder inside it. – Hrvoje Matic Apr 22 '17 at 05:53
  • @Andrii is there a place to get them from? – Sam Storie Jun 20 '17 at 22:24
  • I use this tutorial http://blog.ostebaronen.dk/2016/04/installing-gapps-in-visual-studio.html – Andrii Jul 07 '17 at 22:27
  • 1
    I would add one more step: 12. Restart emulator – Orhan Feb 12 '18 at 15:49
  • where do I find this `install_zip.sh`? – CybeX Feb 11 '20 at 08:23
10

Now you can just drag&drop proper Gapps file to working Emulator and then you should see something like this:

enter image description here

  • 1
    Note: this also requires adb to be installed and added to the path variable. – sibbl Apr 17 '16 at 12:33
  • What must be added to which variable? – Andrii Dec 29 '16 at 22:49
  • 1
    This should be the accepted answer. Note that for this to work you shouldn't launch the emulator as administrator. – Gabriel Jan 11 '17 at 02:43
  • 1
    Use this link to download files to drag&drop. http://www.devfiles.co/download/7m2VdVjQ/gapps-kk-20140105-signed.zip this is also what OP suggested. – Teoman shipahi Jun 01 '17 at 01:46
  • yeah, but it give me this error when clicking on install and shut down File transfer failed. Error: Unable to install the file through Adb. Connecting to Android Device using Adb failed. missing port in specification: tcp: 169.254.190.187 – TheEhsanSarshar Aug 17 '19 at 12:24
9

Drag and drop doesn't work if you start the emulator from Visual Studio when you are running Visual Studio as an administrator. To be able to drag and drop run the emulator from the start menu (not as administrator) not from Visual Studio.

petervandenhout
  • 176
  • 2
  • 8
  • You shouldn't run VS in admin mode. – JCKödel Jul 18 '16 at 15:50
  • I agree normally you shouldn't run in admin mode, but it's only to install the gapps.zip after that restart the emulator in normal mode. – petervandenhout Jul 19 '16 at 16:22
  • It has nothing to do with running from start menu vs Visual Studio (I will edit the answer). I am voting up this answer however, because, for me, running Visual Studio as an admin was causing the problem. I ran as admin instinctively thinking nuget or android sdk manager would need admin access. I realize in retrospect that is not a very valid thought considering how uac works. In any case, Thanks! This saved me. I was going nuts. I learned two things here: 1) Dont run VS as an admin and 2) How to fix my drag and drop issue. – Evan de la Cruz Jul 23 '16 at 00:20
  • Just another comment about admin mode: Visual Studio installs Android SDK on Program Files (x86). It is just plain stupid, as SDK manager (or AVD Manager) cannot write on Program Files (x86)\Android without admin rights =\ – JCKödel Jul 27 '16 at 18:05
7

It seems that the emulator hangs trying to install files if it cannot find adb.exe.

  1. Ensure you have the Android SDK installed

  2. If you run regedit.exe and look at the HKEY_LOCAL_MACHINE\Software\Wow6432Node\Android SDK Tools reg key, there is a Path string value that points to a location on disk. Double check to make sure that there is a copy of adb.exe located in the platform-tools directory under that path.

Hope this helps.

Matt
  • 71
  • 1
4

Found a solution on the web that works. The article suggests it only works for Android 5.1, I haven't tried Marshmallow.

http://www.rajapet.com/2016/03/adding-google-play-services-to-visual-studio-android-emulator.html

  1. Start "Visual studio emulator for android" from the start menu

  2. Create a new emulator for Lollipop, 5.1.1 (API Level 22), start it up

  3. As VS emu runs under x86, we need the "ARM Translator", found on this page:

http://www.techbae.com/download-install-arm-translation-v1-1-zip-genymotion/ ([TechBae.com]Genymotion-ARM-Translation_v1.1.zip)

Drag the file to the emulator window, close and restart the emulator if it doesn't automatically.

  1. Install gapps from http://www.teamandroid.com/gapps/, eg gapps-lp-20150314.zip

Just download, drag to emulator, restart

  1. Wait for app optimization to finish

  2. Open Play Store, ignore any errors. If play store hangs, kill it and start again

  3. Sign in

  4. Expand the side menu

  5. Go to settings

  6. Scroll down to Build version, click/tap. You should get a message that a new version of the play store will be installed

  7. Wait for the XDE.exe process to stop downloading

  8. Restart the emulator

  9. Go back to play store, side menu, click Build version - Ensure it is up to date. If not, let it download

  10. Install an app that uses play services, eg Maps to verify

Michael Ribbons
  • 1,753
  • 1
  • 16
  • 26
3

I tried all the previous answers, including the accepted one about running the install_zip.sh shell script, but nothing worked right for me for VS emulators of Android Lollipop (5.1) and Marshmallow (6). The problem seems to be also that Gapps has now some native code, processor specific, and most Gapps packets available for download are compiled for ARM processors. I tried OpenGapps which does have processor specific packages, but their complex installation scripts didn't work for me in VS emulators.

I finally found a Gapps package prepared for ASUS Zenphone 2, which does have an Intel processor - specifically I downloaded the package recommended here, and that installed fine with just drag and drop on Visual Studio emulator for Android 5.1

gregko
  • 5,642
  • 9
  • 49
  • 76
  • 1
    Note: The [opengapps](http://opengapps.org/) x86 package didn't work for me out of the box on Marshmallow. I had to create a folder named system/ with an empty file in the ZIP for the drag and drop to install properly. – Yunyu L. Jan 18 '16 at 17:24
  • 2
    @vemacs please explain exactly what you did. I downloaded just now open_gapps-x86-5.1-nano-20160118.zip. Created a 'system' folder in it, copied there a 0-length text file (named readme.txt) and dragged on Android 5.1.1 Visual Studio emulator. There was no error message this time, the emulator said that it installed something and will now shut down, but after a restart no change, no Google Apps at all. – gregko Jan 19 '16 at 17:39
  • 1
    I've gotten it to install Gapps on the Marshmallow images. I've described it here: http://blog.ostebaronen.dk/2016/04/installing-gapps-in-visual-studio.html Steps followed: 1. Install Gapps for Lollipop 2. Add Google Account after reboot 3. Install Gapps for M job done. More detailed description in the blog post. – Cheesebaron Apr 05 '16 at 20:55
  • @Cheesebaron, you should submit that as an answer. Your post is the only thing that worked for me. – Matt Honeycutt Aug 05 '16 at 19:35
3

Following the instructions above, I could NOT get Google Play Store to launch successfully on my Marshmallow 6.0.0 Tablet API-23 VM in VS Emulator for Android.

I've tried all the troubleshooting methods mentioned above to no avail.

What finally worked for me was installing (dragging & dropping) the PREVIOUS version of GAPPS (gapps-lp-20150314.zip) for Android 5.1 Lollipop API-22 in my Marshmallow 6.0.0 VM.

Worked like a charm!

http://www.teamandroid.com/gapps/

http://www.devfiles.co/download/fAgtiEoX/gapps-lp-20150314.zip

Alex
  • 228
  • 4
  • 8
  • Thank you, this one worked perfectly for me, note that I then had to allow the emulator to update Play services before anything would work but this was by far the simplest answer – dougis May 31 '18 at 13:41
1

Tomasz Cielecki pointed out a solution that involves installing gapps twice.

First install the gapps downloaded from here, reboot the system and then install gapps again with a version downloadable from here.

At least this worked well for me.

Alexander Pacha
  • 9,187
  • 3
  • 68
  • 108
1

You could just use an Android Emulator image (AVD), similar to a VM image, one that has a Google Play services installed. That would be easier than trying to install it in the emulator. Usually, you can see this Android Studio under Tools > Android > AVD Manager and create a Virtual Device and select from the images which has Google Play Services already.

warfreak92
  • 324
  • 4
  • 15
0

Now Docker + Hyper-V + Android Emulator is possible without needing VS Android Emulator (in fact they seem to be a discontinued job).

Now the Google's emulators work well even with Hyper-V activated.

More info here about how to make it work here (spoiler: it is a simple tick in a checkbox) https://android-developers.googleblog.com/2018/07/android-emulator-amd-processor-hyper-v.html

jamesbluecrow
  • 134
  • 1
  • 5