How to download Google Play Services in an Android emulator?

236,603

Solution 1

Check out Setting Up Google Play Services which says:

To develop an app using the Google Play services APIs, you need to set up your project with the Google Play services SDK.

If you haven't installed the Google Play services SDK yet, go get it now by following the guide to Adding SDK Packages.

To test your app when using the Google Play services SDK, you must use either:

  • A compatible Android device that runs Android 2.3 or higher and includes Google Play Store.
  • The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher.

Solution 2

For api 21+ you can use system image with Google Play as I describe below.

For api 19+ (Android 4.4 Kitkat) you can use system image x86 with Google Api (I was able to use it).

For api 17+ (Android 4.2.2) you can TRY to use system image ARM with Google Api (It didn't work for me).

I was able to install Google Play and Google Services as separate apks to pure system image api 16 and 17, but they don't really work after that (services crush and play not opens). So seems like it is not possible to make them work on pure AVD image because they should be installed with root access. The same for updating Google Services on AVD system image with Google API preinstalled - can't update because of incompatible certificates, can't uninstall even using adb because don't have access.


How to setup AVD system image with Google Play

Now even better solution exist: using AVD image with build-in Google Play Services. It will enable you to use Google Services including Google Play. Also you will be able update it without re-creating AVD image.

Open AVD manager and choose create new device. You should use device definition with play store icon.

1

Then choose system image for it. You should choose one with Google Play and NOT with Google API.

2

Then launch new device.

3

You can update Play Services as shown on screenshot, or manually on device..

4

Solution 3

This is how you make Android Google Maps API v2 work on your emulator.


Create a new emulator

  • for device choose "5.1'' WVGA (480 x 800: mdpi)"
  • for target choose "Android 4.1.2 - API level 16"
  • for "CPU/ABI" choose "ARM"
  • leave rest to defaults

these are the settings that are working for me. I don't know for different ones.


Start the emulator


install com.android.vending-1.apk and com.google.android.gms-1.apk via ADB install command


The longer answer is on my blog post about this issue https://medium.com/nemanja-kovacevic/how-to-make-android-google-maps-v2-work-in-android-emulator-e384f5423723

Solution 4

I came across another solution to use the Google play services on an emulator. The guys at http://www.genymotion.com/ provide very fast emulators on which you can install Google play services. They just need you to sign up to begin downloading and you need Virtual box installed. At the moment they cater for Android 16 and 17 but more are on the way.

Solution 5

In the current version (Android Studio 0.5.2) there is now a device type for "Google APIs x86 (Google Inc.) - API Level 19".

Share:
236,603
WitaloBenicio
Author by

WitaloBenicio

I'm the Head Frontend Developer at meutudo. I have 8 years of experience in software development and my current tech stack is React | React Native | Typescript | Javascript.

Updated on November 01, 2020

Comments

  • WitaloBenicio
    WitaloBenicio over 3 years

    I want to use Google Play Services API in my application, but when I open the emulator to test my application it sends me a message that says "Google Play Services must be downloaded". I know that occurs because I coded this test in my MainActivity in the method onResume().
    I want to know how I can install Google Play Services in my emulator, because soon I will need to test my maps.

  • WindsurferOak
    WindsurferOak almost 11 years
    There has been updates, developer site quoted: "The Android emulator with an AVD that runs the Google APIs platform based on Android 4.2.2 or higher."
  • Skitterm
    Skitterm over 10 years
    I tried using the Android API (version 4.3) and it didn't work, so the key is to use the Google API (version 4.3). Since they were the same version number, I didn't realize why it wasn't running at first.
  • Reck
    Reck over 9 years
    They used to until Google told them to stop providing an infinitely better service than Google ever has, and forced them to rip out the Play Store from their images.
  • Juan Cortés
    Juan Cortés over 9 years
    Said Oh!, went to create a new emulator for testing tablets on my existing genymotion app, the read your comment and hated people I don't know for a second.
  • Yar
    Yar almost 9 years
    I am using Google APIS ver. 22 with Intel x86_64. Does not work.
  • BoneGoat
    BoneGoat over 8 years
    The important thing here is what @Skitterm wrote. The AVD must have Google APIs as a target. Interestingly selecting a lower API target than 23 (Marshmallow) results in the device trying to update the Google Play services which always fails for me.
  • Laser Hawk
    Laser Hawk over 7 years
    I know this is old but Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]
  • William Entriken
    William Entriken over 7 years
    I did: Android Studio (2.2.3); Tools -> Android -> AVD Manager; Create Virtual Device...; 5.1" WVGA, Next; Nougat (7.1.1), Next; Finish. The resulting emulator did not have a Google Play Store icon.
  • tedebus
    tedebus almost 7 years
    If your interest is not relative to the architecture, I prefer emulate my projects on x86-x84 CPU/ABI, using hosting machine's GPU. Emulation is quite different in terms of responsiveness.
  • ronenmiller
    ronenmiller over 6 years
    Which android studio version should one use to have this option?
  • B-GangsteR
    B-GangsteR over 6 years
    @ronenmiller I am using last stable version, now it's 2.3.3. But it should not depend on Android Studio version. It depends on Android System Image version, and maybe on Android Virtual Device Manager's version, but I'm not sure about last. I just always update everything to last stable version.
  • Alberto M
    Alberto M about 6 years
    links are broken
  • Nemanja Kovacevic
    Nemanja Kovacevic about 6 years
    Hi Alberto, situation has changed in the 5 years from this answer so this is probably not going to fix your problem.
  • WSS
    WSS about 6 years
    I am seeing 'connection to server failed errror'
  • Emaborsa
    Emaborsa over 5 years
    Isn't available on 3.1.3
  • B-GangsteR
    B-GangsteR over 5 years
    @Emaborsa did you chose image with Google Play or Google API? I'm using Android Studio 3.1.4 now and everything works fine.
  • Emaborsa
    Emaborsa over 5 years
    @B-GangsteR Yes I did
  • KansaiRobot
    KansaiRobot about 5 years
    genymotion was a great emulator but it seems it does not work with maps now :(
  • LewlSauce
    LewlSauce almost 5 years
    Has anyone ever gotten this to work? It seems that using an Android image with Google API does not work with Google Play.