Manage versions android libraries

0

Currently in my application I have the following imports of libraries 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:+'
  • What does: + definitely do?
  • Does it bring the latest version available on the mobile that will run the app?
  • Or what's in my Android Studio at compile time?
  • I have been having problems, for example, with some clients with older cell phones, which the map service has not worked perfectly because Google Play Services is not up to date. Currently%% of my App is compileSDKVersion

        
    asked by anonymous 04.12.2017 / 14:09

    1 answer

    1

    The use of dynamic versions is a feature of Gradle, and is documented on their site a>:

      

    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, the 'higher' static version is preferred over a 'lower' version.

    In compile time of the project Gradle will translate the + to the last version it finds in the accessible repositories.

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

    The way the interaction between the client library and the APK installed on smartphones happens is described on the Play Services website

    a>.

      

    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 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 will not have an adverse impact on your app's file size.

         

    [...]

         

    The Google Play services APK contains the individual Google services and runs a background service on 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 each Google service, which provides consistency for both you and your users.

    Using the latest version of Play Services gives you the added benefit of always having the new features and security updates available.

    But as you realize this comes at a price. The client library must run in conjunction with a compatible version of Google Services APK .

    Summarizing

    As you described, always you compile your app and Gradle finds a new version of Play Services, it will use it. Your user must then have a compatible version of Google Services APK installed on his or her smartphone.

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

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

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

    Note: In general, any kind of dynamic dependency can lead to problems, not just Play Services. Avoid them whenever possible .

        
    04.12.2017 / 17:08