How to update Google Play Services for Android Studio 2.2 emulators?

☆樱花仙子☆ 提交于 2019-12-17 07:42:09

问题


There are a number of variations of this question, however most are very old, and don't really answer the question at all. I'm NOT asking how to install Play Services, that is installed in the Studio 2.2 emulators.

The problem is that these emulators are using an old version of Play services.

When I run a test app that uses Firebase to facilitate Google login I get this alert dialog from a Nexus 5 API 23 emulator:

In the onCreate method of my login activity I have this code:

int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    switch(result) {
        case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
            Log.d(TAG,"SERVICE_VERSION_UPDATE_REQUIRED");
            break;
        case ConnectionResult.SUCCESS:
            Log.d(TAG, "Play service available success");
            break;
        default:
            Log.d(TAG, "unknown services result: " + result);

    }

This always returns SERVICE_VERSION_UPDATE_REQUIRED.

Clicking update in the alert dialog does nothing that I can detected. In the debug log I get this message when Play Services startup fails:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9080000 but found 8489470

My application runs fine on a real Android device.

What simple thing am I missing?

TIA


回答1:


This may not be relevant to this question now, but wanted to post it here for future explorers, so that they see some land at the end of the sea. I had been struggling with this out of date Google Play Service on my Nexus 5 x86 emulator running API 25 and trying Firebase notification. I am using Firebase 10.0.1 which needs Google Play Services 10.0.1. But on my emulator, I always used to get the message

W/GooglePlayServicesUtil: Google Play services out of date. Requires 1008400 but found 9874900

W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}

I had searched extensively a way to update the Google Play Services on my emulator, and whatever was suggested never worked. Finally, I tried creating a new emulator Nexus 5 x86_64 and API 24. Voila!!! It has Google Play Services 10.0.1 and my app works now.

It really beats me why the x86 image does not have the latest Google Play Serviecs and it does not allow me to update it in any manner, while the x86_64 image has the latest Google Play Services.

Hope this helps someone struggling with Google Play Services.




回答2:


As for my case, I tried checking for updates on Android Studio, as well as the Google Play Services, and restarted Android Studio. Then the update dialog appeared, which allows me to update the emulator images with the correct Google Play Services version.

Wait for the update to finish, then create new AVDs based on the newly updated images, and everything is good to go.




回答3:


Assuming you're using Android's default AVDs, as opposed to Genymotion, you just have to make sure everything has been updated.

This is what's working for me. If you are using using the current version of play services, 9.6.1 or higher, make sure of the following:

  1. Your build tools version is 24.0.3 or higher
  2. In the SDK Manager (SDK Platforms tab):
    • If testing Nougat, your emulator is using Google APIs System Image Revision 8 or higher (I'm using "Google APIs Intel x86 Atom_64 System Image")
    • Google APIs is installed and updated (For me, "Google APIs, Android 24" - Revision 1.0.0)
  3. In the SDK Manager (SDK Tools tab):
    • Android SDK Platform Tools is version 24.0.3 or higher
    • Android SDK Tools is version 25.2.2 or higher
    • Google Play Services is installed and using version 33 or higher
    • (Probably optional) Google Repository is installed and version 36 or higher

After ensuring all of that, and restarting Android Studio (because better safe than sorry), make a new AVD. I mainly use the following settings: - Nougat (API 24) - ABI - x86_64 - Target - Android 7.0 (with Google APIs)

This is working for me, as I was having the same problem this morning until I updated everything. Good luck :)




回答4:


In case people are still looking for an answer and haven't found any solution that fixes or updates the Google Play Services on their emulators, here's what helped me. I had followed multiple SO posts that recommend getting latest SDK build tools but missed a very important update. That is, from the SDK Platforms you must update/download

Google Play Intel x86 Atom System Image

A picture is worth a thousand words:




回答5:


This packages will only work for Android 4.2.2 and higher in these answer i am taking an example of (API 17).and it will do work .

Let’s begin by launching the SDK manager. We will first need to ensure that Android 4.2.2 (API 17) and higher is installed.

[shubham@localhost tools]$ ./android sdk

If not, check the top level element, “Android 4.2.2 (API 17)”, click “Install 6 Packages”, and accept the license agreement.

Setting up the image

To get the right image for your virtual device manager:

  • Open the Android SDK Manager
  • Open the group Android 4.2.2 (API 17)
  • Check Google APIs
  • Check ARM EABI v7a System Image

    [![Google Android sdk required tool][1]][1]

Once installed, close the SDK manager and launch the AVD manager. Here we’ll need to create a new AVD which utilizes the Android 4.2.2 platform and has snapshots enabled so that any changes we make are persistent.

[shubham@localhost tools]$ ./android avd

Next we need to pull down the appropriate Google Apps package. Using Android 4.2.2 (API 17) and higher we must use the appropriate package according to below link.

[https://www.androidfilehost.com/?w=files&flid=5649][2]

Once downloaded, extract the archive. In order to install Google Play, we’ll need to push the following 3 APKs to our AVD (located in ./system/app/):

  • GoogleServicesFramework.apk
  • GoogleLoginService.apk
  • Phonesky.apk

However, before we do, we need to make some minor modifications to our AVD. Let’s launch the newly created AVD using the following command. Note that we’ve specified a partition size of 512MB. This is to ensure that our AVD has enough capacity to install the Google Play Store and its dependencies.

[shubham@localhost tools]$ ./emulator -avd Test -partition-size 512 -no-boot-anim

This may take several minutes the first time as the AVD is created. Once started we need to remount the AVD’s partition and modify the permissions of “/system/app/” as this is where our packages will be installed to.

[shubham@localhost platform-tools]$ ./adb remount
[shubham@localhost platform-tools]$ ./adb shell chmod 777 /system/app

And finally, we can push these APKs to our AVD:

[shubham@localhost platform-tools]$ ./adb push ~/system/app/GoogleServicesFramework.apk /system/app/
[shubham@localhost platform-tools]$ ./adb push ~/system/app/GoogleLoginService.apk /system/app/
[shubham@localhost platform-tools]$ ./adb push ~/system/app/Phonesky.apk /system/app/

Now if your emulator is as slow as mine it may take a few minutes for the package to be installed. You’ll know if the installation hasn’t yet completed if the launcher process repeatedly crashes on you ;)

After a few minutes, 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 your emulator.

Please refer to this link :[http://www.flinkd.org/2013/12/installing-google-play-on-the-android-emulator-api-18/][3]

That should do the work. For more information and tutorial you can watch these video tutorial :-[https://www.youtube.com/watch?v=Nq5mng20PC8][4]

      [1]: http://i.stack.imgur.com/Xn2cX.png
      [2]: https://www.androidfilehost.com/?w=files&flid=5649
      [3]: http://www.flinkd.org/2013/12/installing-google-play-on-the-android-emulator-api-18/
      [4]: https://www.youtube.com/watch?v=Nq5mng20PC8



回答6:


I'm not asking how to install Play Services, that is installed in the Studio 2.2 emulators.

You do seem to be asking how to update it, in which case you do need to know how to install it.

The problem is that these emulators are using an old version of Play services.

That's what the error says, yes.

Possibility one: Your emulator and/or SDK library is outdated, and you need a new AVD.

Possibility two: Go download the latest APK for Play Services and install it. You can use adb to install it, for example. Genymotion will allow you to install APK files by dragging it onto the emulator.




回答7:


What worked for me is:

  1. Check for and install any new updates. You specifically want to make sure that you're installing the newest version of Google Play Services. Also, you can check for the version of Google Play Services that you're using in the SDK Manager.

  2. Delete all your emulators in the AVD (Android Virtual Device) Manager.

  3. Create new emulator(s).

Should work fine afterwords!




回答8:


Same problem with API 25, Studio 2.2.3, resolved changing line

compile 'com.google.android.gms:play-services:10.2.0'

to

compile 'com.google.android.gms:play-services:9.8.0'

in build.gradle(Module:app), while waiting for an update of Google Play Services in emulator images.



来源:https://stackoverflow.com/questions/37798911/how-to-update-google-play-services-for-android-studio-2-2-emulators

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!