Google Play Services in emulator, implementing Google Plus login button etc

Marius Kjeldahl picture Marius Kjeldahl · Apr 14, 2013 · Viewed 65.1k times · Source

When integrating a Google Plus login button in an Android app, I'm observing some differences in how the button appears on an actual device and in the emulator. I am aware of the fact that the Google Plus services APKs are not installed in the emulator, but this can be worked around by pulling the APKs from a device and installing them into the emulator using APK.

My current "implementation" simply includes the login button in a layout, by referring to the button with the following XML code:

<com.google.android.gms.common.SignInButton
    android:id="@+id/sign_in_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

When I test my app on the device, the button appears all red and shiny, according to the guidelines mentioned here https://developers.google.com/+/mobile/android/sign-in . But when running on the emulator, it's just a normal button (grey background with black text) saying "Sign in with Google".

Any idea why the results are different? I've made sure I'm running the same API level, and the resource does seem to get pulled in correctly also on the emulator since it shows the actual login button (but with a different look).

Update: Found a clue in logcat; the message "Sign in button not found, using placeholder instead." pretty much explains why I'm seeing the grey dull button on the emulator. Still need to figure out why; could be the "copy google plus apk's from device" hack isn't working properly.

Answer

class picture class · Jun 22, 2013

Google Play services works on the 4.2.2 versions of the Android Emulator and is officially supported as described in the Android documentation: Setup Google Play Services.

Update

You now can use the Intel/x86 images (HAXM-compatible) for API 19 and newer and for ARM, Google Play Services is available on most images.

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

enter image description here

To create the Virtual Device:

  • Open the Android Virtual Device Manager
  • Create a New device
  • Enter an AVD name
  • Set the target to Google APIs (Google Inc.) - API Level 17
  • Save your Virtual device and start it...

Note CPU/ABI will be fixed as ARM

enter image description here

Now you should be able to use the Google Play Services in the emulator. Of note, you need to set your target appropriately in your Android project to the Google APIs in order for Google Play Services to work.