Manage android library versions

Asked

Viewed 127 times

0

Currently in my application I have the following imports library in my build.gradle:

compile 'com.google.android.gms:play-services-maps:+'
compile 'com.google.android.gms:play-services-gcm:+'
compile 'com.google.android.gms:play-services-location:+'
  1. What definitely :+ does?
  2. It brings the latest version available on mobile that will run the app?
  3. Or that exists in my Android Studio at the time of compilation?

I have had problems, for example, with some customers with older cell phones, which the map service has not worked perfectly, because the Google Play Services not be up to date. Currently the compileSDKVersion of my App is the 26

1 answer

1

Using dynamic versions is a feature of Gradle, and is documented on their website:

If the dependency is declared as a Dynamic version (like 1.+), Gradle will resolve this to the Newest available Static version (like 1.2) in the Repository. For Maven repositories, this is done using the Maven-Metadata.xml file, while for Ivy repositories this is done by directory Listing.

[...]

Once each Repository has been inspected for the module, Gradle will Choose the 'best' one to use. This is done using the following criteria:

For a Dynamic version, a 'Higher' Static version is Preferred over a 'Lower' version.

In compilation time of the project Gradle will translate the + for the latest version that it finds in the accessible repositories.

So when you install the app this version has already been set.


The way in which the client library interacts with the APK installed on smartphones is described on the Play Services website.

The client library contains the interfaces to the individual Google services and Allows you to obtain Authorization from users to Gain access to These services with their credentials. It also contains Apis that allow you to resolve any issues at Runtime, such as a Missing, disabled, or out-of-date Google Play services APK. The client library has a light Footprint if you use Proguard as part of your build process, so it won’t have an adverse Impact on your app’s file size.

[...]

The Google Play services APK contains the individual Google services and runs as a background service in the Android OS. You Interact with the background service through the client library and the service Carries out the actions on your behalf. An easy-to-use Authorization flow is also provided to Gain access to the each Google service, which provides Consistency for Both you and your users.


Using the latest version of Play Services offers the advantage of always having new features and security updates available.

But, as you realized it has a price. The client library needs to run in conjunction with a compatible version of Google Services APK.


In short

The way you described it, at all times that you compile your app and Gradle find a new version of Play Services, he will use it. Your user should then have a compatible version of Google Services APK installed on his smartphone.

The question you should ask yourself is: It is absolutely necessary for my application to always use the latest version of Google Play Services?

The answer is almost always nay. Using the latest version is almost always unnecessary, except in case of security updates or new essential features.

My recommendation is that you choose a fixed version and use it, updating only as needed.


Note: In general, any type of dynamic dependency can bring problems, not only that of Play Services. Avoid them whenever possible.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.