How to manage Google Play Services update in Android app?
I kind of lost my information on how to manage google play services in the app.
doc indicates to download the latest version of game services and install it in gradle.build with a version number like
dependencies {
//...
compile 'com.google.android.gms:play-services:6.1.+'
}
He then explained that:
Be sure you update this version number each time Google Play services is updated.
What does it mean? Does this mean that every time a new version is released it has to be updated in the app and its version number reset to build.gradle
(which means that every time this happens the new apk must sound crazy)?
He also pointed out that the following tag should be added in the manifest:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Why is there no explanation?
Then I found out in that SO answer that the version of Google Play Services should be checked in the app using something like
// Check status of Google Play Services
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
// Check Google Play Service Available
try {
if (status != ConnectionResult.SUCCESS) {
GooglePlayServicesUtil.getErrorDialog(status, this, RQS_GooglePlayServices).show();
}
} catch (Exception e) {
Log.e("Error: GooglePlayServiceUtil: ", "" + e);
}
and this will open a dialog box to download the latest version in case the app is not updated.
But what does he do? Does it replace the lib set when building apk? In this case, how does it manage the version number set to build.gradle
?
Can anyone help clarify this?
source to share
Does this mean that every time a new version is released [..] a new apk should be executed
Not. When you release a new version of your application, check for updates to this library as it might fix something. But you can keep using old versions, if you are lazy and don't check out new versions, they won't suddenly stop working.
<meta-data ...
Why is there no explanation?
This is information used by GooglePlayServicesUtil
the game services infrastructure installed on your phone to make sure everything works fine even if your application has an older version of the library in use. A dialog is an easy way to tell the user to do this.
.. which will open a dialog box to download the latest version if the one that is not updated in the application. But what does he do?
There are two components required on the device to use google services.
1) Application Play Framework Framework.
https://play.google.com/store/apps/details?id=com.google.android.gms
It provides services that manage Google login information for you, for example. The user must install and update the version through the play store when required by the application.
2) Service Library.
What you ship with your application and all it does is provide classes that use the services provided by the above application. You have to update the library via gradle.
The library requires a specific version of the application. So, to check if this app is installed and has at least the required version, you do the part GooglePlayServicesUtil
.
This is not a problem when the application is never more than your library. He will know on a basis <meta-data
how to handle older versions.
source to share