ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Follow publication

Google Play Services in Android — explained

What is it?

It is a client-side library from Google, using which app developers can use the latest services supported/provided from Google on Android devices. It also takes care of authentication flows required to use such services. Can be used only on devices endorsed by Google.

Some example Google services provided are Google Maps, FusedLocation Provider, Google Cloud Messaging, Google Vision, Google SafetyNet and so on…

Why it exists?

We Android developers use it very frequently in our apps, as part of integration instructions given by various services. But why we need it is not known to many of us. Below are various reasons Google came up with the approach

  • Different Android OS versions: Android is notorious for its fragmentation problem. But this is one of the major factors behind the Google Play service idea inception.
  • No updates from OEMs: As we know Android is an open source project, which OEMs (Samsung, Oneplus, Xiaomi, etc..) can use and ship devices with some customizations. They come up with different variants of each model and most of the time not able to release Android OS updates in a timely manner for these variants. As this is a costly affair and not economic for them. Most of the users are left with one choice to keep using the same OS version for a very long duration.

Possible Solution:

Embed Google services in the app on a need basis, Similar to the Android app compat and support libraries. Right?

But Google didn’t go with this approach because of the below reasons:

  • App Size: Embedding this in the app would have caused an increase in app size. It needed lots of native libs, which impacts heavily on app size
  • Common services: Many apps needs common services like push notifications, fused location, maps and so on…, It makes sense to provide them in a way so that all apps can use in a shared manner
  • Library Updates: Releasing updates, bug fixes and providing new features would not have been possible with embedding as a library. Google has to rely on developers to update apps. Also, it would have been harder to maintain with the latest library version for developers

Selected Solution:

Provide all Google services in apk and expose API interfaces for these services as an embeddable library. We knew these as

  • Google play services libraries: These are just API interfaces & needs to be embedded in the app. Initially it was a single library, eventually, Google started publishing smaller artifacts for each Google Service, so that it doesn’t affect much on total dex method count
  • Google play services apk: This can be downloaded from Google Play Store like a normal app. And using this Google can control releasing updates, new features & bug fixes to older Android OS versions as well.

How it works:

  • Google silently download/updates Google play service apk in background
  • Developers embedds Google Play services libraries in app and use these services
  • You can check Setting up instructions here

Features:

  • API interfaces, multiple components are provided with a small footprint
  • New APIs, bug fixes are available on all Android OS versions(currently API level 16 +)
  • APIs to check availability of newer versions and upgrade/error dialogs
Image credit: https://developers.google.com

Before Google Play Services

  • Developer dilemma: The trade-off, dropping support for older versions
  • Search for available libs or write your own implementations
  • Nonavailability of new services on older Android OS versions

After Google Play Services

  • Seamless availability of newer APIs for Google Powered services
  • Focus on core features, rather than searching/developing Google services solutions

Downsides(for developers)

  • Features dependent on Google Services can’t be used on Android devices which are not endorsed by Google.

What’s in for users

  • Better apps, because devs can focus on the core app features
  • Apps with latest Google features on older Android Devices as well

Downsides — users perception

  • Google Play Service apk: a useless app sitting in the device which eats a lot of space and no idea why
  • Irritating Update Google Play services prompt on app open sometimes

You can see many bad User reviews are filled with similar complaints here

NO love from Google content team

Screenshots added by Google says it all :)

Image credit:https://play.google.com

Concluding this blog post now, I hope now you understand Google Play services better :)

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Akhil Gupta

Android Dev @gojektech, twitter:@akhilgupta_me

Responses (1)

Write a response

Well explained, I think every developer understand the main purpose of Google Services, the problem is the user pretty much gives away it’s privacy to Google, I am not a fan of those Google Play Services silent updates, and the fact is closed source…

--