Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 272
Marius Kjeldahl Avatar asked Apr 14 '13 15:04

Marius Kjeldahl


People also ask

Can I use Google Play on emulator?

Yes, you can enable/use Play Store on Android Emulator(AVD): Before that you have to set up some prerequisites: Start Android SDK Manager and select Google Play Intel x86 Atom System Image (Recomended: because it will work comparatively faster) of your required android version (For Example: Android 7.1. 1 or API 25)

How do I disable Google Play Services on my emulator?

Go to Settings > Applications > All > Google Play Services > Tap Disable > Tap OK to confirm. Method 2. If you find the Disable checkbox is grayed out, please Go to Settings > Security > Device administrators > Disable Android Device Manager.

What is Google Play emulator?

The Android Emulator simulates Android devices on your computer so that you can test your application on a variety of devices and Android API levels without needing to have each physical device.


1 Answers

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.

like image 95
class Avatar answered Oct 16 '22 15:10

class