How to Download Google Play Services in an Android Emulator

How to download Google Play Services in an Android emulator?

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.

updating Google play services in Emulator

Update On 18-Dec-2017

You can update Google Play Services via the Play Store app in your emulator just as you would on a physical Android device from API 24.

check Emulator new features added with stable update from Android Studio v 3.0

Google Play Support - From Google : We know that many app developers use Google Play
Services, and it can be difficult to keep the service up to date in
the Android Emulator system images. To solve this problem, we now
offer versions of Android System Images that include the Play Store
app. The Google Play images are available starting with Android Nougat
(API 24)
. With these new emulator images, you can update Google Play
Services via the Play Store app in your emulator just as you would on
a physical Android device. Plus, you can now test end-to-end install,
update, and purchase flows with the Google Play Store.


Quick Boot - Quick Boot allows you to resume your Android Emulator
session in under 6 seconds

Android CTS Compatibility

Performance Improvements - With the latest versions of the Android
Emulator, we now allocate RAM on demand, instead of allocating and
pinning the memory to the max RAM size defined in your AVD.

Virtual sensors

Wi-Fi support

GPS location and Many more...

OR

Update this SDK Build-Tools and Android Emulator to latest and this alert message will not come again,

Settings --> Android SDK --> SDK Tools(tab) --> Android SDK
Build-Tools

Sample Image

How to install Google Play Services in a Genymotion VM (with no drag and drop support)?

As of Genymotion 2.10.0 and onwards, GApps can be installed from the emulator toolbar.
Please refer to answer by @MichaelStoddart.

Next follows former answer kept here for historic reason:

Genymotion doesn't provide Google Apps. To install Google Apps:

  1. Upgrade Genymotion and VirtualBox to the latest version.

  2. Download two zip files:

    - ARM Translation Installer v1.1

    - Google Apps for your Android version: 2.3.7 - 4.4.4 or 4.4 - 6.0 (with platform and variant) You can also find the GApps list in the wbroek user GitHubGist page.

  3. Open Genymotion emulator and go to home screen then drag and drop the first file Genymotion-ARM-Translation_v1.1.zip over the emulator. A dialog will appear and show as file transfer in progress, then another dialog will appear and ask that do you want to flash it on the emulator. Click OK and reboot the device by running adb reboot from your terminal or command prompt.

  4. Drag and drop the second file gapps-*-signed.zip and repeat the same steps as above. Run adb reboot again and, once rebooted, Google Apps will be in the emulator.

  5. At this point 'Google Apps Services' will crash frequently with the following message google play services has stopped working. Open Google Play. After providing your account details, open Google Play and update your installed Google Apps. This seems to make Google Play realize you have an old Google Play Services and will ask you to update (in my case, updating Google Hangouts required a new version of Google Play Services). I've also heard that simply waiting will also prompt you to update. The 'Google Play Services' app doesn't seem to appear otherwise - you can't search for it. You should then see an offer to update Google Play Services. Once the new Google Play Services is installed you will now have stable, working access to Google Play

How to update Google Play Service in the Android emulator

This happen everytime you have a mismatch between the version of Google Play Services installed in your device (or image), with the ones requested by the Play Services libraries you are using.

The first thing to do is to be sure that the image you are using is updated to the last version.

The second thing is to know which version is currently installed in the image.
You can found it going in Settings->Apps->Google Play Services and you can find the version like in the example image below

Sample Image

Then when you know which version is installed, you could try to:

  • Update the Play Services with newer packages you can find online here.
    To use this technique you need to follow this small guide:

    Step 1 Create a new AVD with an API image which doesn't contain the Google APIs.

    This is the key of everything, in this way you can't obtain
    INSTALL_FAILED_UPDATE_INCOMPATIBLE because there are no GPS already
    installed in your emulator :D).
    In your case, for API 18, you need to download the Android image indicated with the red arrow below.
    Sample Image
    Then finish to setup the AVD.

    Step 2 You need to know which version of the Google Play Services to download. You said in the emulator with Google API there is 9.2.56 version, which doesn't work with your 10.0.1 libraries in your app. So let's install GPS with at least version 10.2.91 from ApkMirror, i selected the version with ABI x86 (because you downloaded the x86 version) and with Density nodpi (so you can be sure that it will work on every screen size). Click here to download the APK

    Step 3
    Launch the AVD configured in Step 1 and drag the downloaded GPS apk on top of it. It should install the Google Play Services without problems. Run your app and see if it works.

  • Use a real phone (if you have access to a real phone :D) where Play Services can be updated easier from Play Store

  • Use a downgraded version of the Play Services library in you app (be carefull with this because if you used some new APIs your app will not compile)

Is Google Play Store supported in avd emulators?

Starting from Android Studio 2.3.2
now you can create an AVD that has Play Store pre-installed on it. Currently, it is supported on the AVD's running

  • A device definition of Nexus 5 or 5X phone, or any Android Wear
  • A system image since Android 7.0 (API 24)

Official Source

For other emulators, you can try the solution mentioned in this answer.



Related Topics



Leave a reply



Submit