如何在 Android Studio 模拟器中安装 GooglePlay 应用程序?

我对使用 Android Studio 是完全陌生的,我正在尝试在模拟器上安装 GooglePlay 应用程序。我已经安装了 Google RepositoryGoogle Play Services以及来自 SDK 管理器的 Google APIs x86 Atom System Image,我能够为我的示例应用程序设置 Google Play Services。

现在我想在我的仿真器上安装 GooglePlay 应用程序。这怎么可能呢?任何建议或解决方案本身将不胜感激。还有,非常感谢你抽出时间。

143863 次浏览

Download Google apps (GoogleLoginService.apk , GoogleServicesFramework.apk , Phonesky.apk) from http://wiki.rootzwiki.com/Google_Apps#Universal_Packages_2

Start your emulator:

emulator -avd VM_NAME_HERE -partition-size 500 -no-audio -no-boot-anim

Then use the following commands:

Remount in rw mode

adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system

Allow writing to app directory on system partition

adb shell chmod 777 /system/app

Install following apk

adb push GoogleLoginService.apk /system/app/.
adb push GoogleServicesFramework.apk /system/app/.
adb push Phonesky.apk /system/app/. # Vending.apk in older versions
adb shell rm /system/app/SdkSetup*

Refer: to this SO Post

All this is not necessary on the latest MM API images.

All that was needed for me was to:

adb remount
adb push Phonesky.apk /system/priv-app/.
adb stop && adb restart

Starting with Android Studio 3.0 Canary 1, you have now some options of devices that come with the Play Store app built-in (like Nexus 5X and Nexus 5 on image below).

enter image description here

Also, you should use a system-image which targets "Google Play" (instead of Google APIs), as said images come with "Google Play" pre-installed, and you can just like a real device open "Google play" and update it.

Update 2022; but even with above, you cannot use the Emulator to test Google Play Billing:

  • You must install your application on a real device to test Google Play Billing,
  • Or, ask Google for "closed testing" permission.

see How to test In-app Billing on an emulator?

On new version of sdk, you could browse:

C:\Users\{$User}\AppData\Local\Android\sdk\tools

Create avd from command line:

android create avd --name bphone --package "system-images;android-23;google_apis;x86_64"

There will be a question asking you to custom profile, say yes, then an asking to install CH Play or not, just type yes.

Then, open AVD Manager inside Android Studio to reconfig. Notes: Remember to change CPU/ABI to x86

After a long while of testing, everything seems to be outdated. I can't find necessary APK's like GoogleLoginService.apk, etc.

I got it to work by installing two virtual devices.

  1. My Device (a Samsung Galaxy Tab A with custom skin and sizes)
  2. A device, which had the "Play Store Available" icon in your AVD-Manager on the site where you can create a new profile.

I installed the first device and the second device with the same Android version, and used one profile from Samsung (because my tablet is a Samsung).

After that step, I compared the config.ini file located in:

C:\Users\USER\.android\avd\DEVICE_ID

On Ubuntu/Linux it'll be in

~/.android/avd/DEVICE_ID

Change the following variables to:

PlayStore.enabled = true
image.sysdir.1=system-images\android-27\google_apis_playstore\x86\
tag.display=Google Play
tag.id=google_apis_playstore

Here's an example diff of what fields will be changed:

Screenshot: AVD Device config.ini differeneces

After that you'll probably have to re-download the system image for the device, which you can do from Tools > AVD Manager.

Here's an example screenshot of what that'd look like:

Screenshot: Installing system image in AVD Manager

Once done, restart the device, and Play store will be installed and ready to use.