Multiple Google Play Services library Versions - android

According to Android developer documentation, Google Play Services library provides an interface to the hosting application so that, at runtime, it can access to Google Play services APK through interprocess communication.
Considering the following configuration where an android application includes Google Play Services library and a SDK that also includes Google Play Services library, as shown below:
MyApplication
Google Play service v.XX
MySDK
Google Play Services v.YY
Since the SDK and the hosting application include different versions of Google Play Services library, is version YY fetched at MyApplication build time instead of version XX ? Is the final application built with the two different versions (XX and YY) and in this case which one is called at runtime?
Best Regards,

You can use command ./gradlew app:dependencies at Android Studio console to see all dependencies and which version is being used.

Related

Which dependency is required for Awareness API?

I want to check out the new Awareness API which is quite new. I’m using Play Services 9.0.2. The documentation has this example:
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(Awareness.API)
.build();
client.connect();
However, there is no hint which dependency needs to been added. Any idea?
I found it out: I need to upgrade to PlayServices 9.2.0 and the dependency is hidden in play-services-contextmanager. Just add those dependencies and here we go:
compile 'com.google.android.gms:play-services-awareness:10.2.4'
Please use the latest play services library, at the time I updated this answer it was 10.2.4
If you want to know the latest Dependency you can use my web tool called DependencyLookup.
Keep in mind that this library was added in the Play Services Repository v31. Make sure that you have at least that version installed in the SDK manager.
You need to add the library of Google Play services to your project.
Set up Google Play services
To access the Awareness API, your app's development project must
include Google Play services. Download and install the Google Play
services component via the SDK Manager and add the library to your
project. For details, see the Android guide to setting up Google Play
services.
Source
Set up Google Play services
To access the Awareness API, your app's development project must include Google Play services. Download and install the Google Play services component via the SDK Manager and add the library to your project. For details, see the Android guide to setting up Google Play services.
which is apparently on the same page you got your code sample from here
Most of the times the number of method references in your app exceeds the 65K limit, your app may fail to compile. So in order to mitigate this problem when compiling your app ,specify only the specific Google Play services APIs your app uses, instead of all of them.
compile 'com.google.android.gms:play-services-basement:9.2.0'
compile 'com.google.android.gms:play-services-contextmanager:9.2.0'
You will find the complete solution here:
http://xordroid.com/create-intelligent-apps-with-google-awareness-api/
Starting PlayServices v9.6.0, contextmanager has been changed to awareness
So, the previous answers won't be working.
The correct dependencies, as of v10.2.4 are
compile 'com.google.android.gms:play-services-basement:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'

Google Play Service Froyo -Jar does not contain package com.google.android.gms.ads

I referenced google play services lib as a library resources to ads from google admob, as per their instructions. But I was getting error for class Adview and AdRequest. When I unzipped the google play services jar I could not locate the package com.google.android.gms.ads. What could be the solution to the problem?
Google Mobile Ads / Admob was added in Google Play Services 4.0, which is not available for Froyo:
With over 97% of devices now running Android 2.3 (Gingerbread) or newer platform versions, we’re dropping support for Froyo from this release of the Google Play services SDK in order to make it possible to offer more powerful APIs in the future. That means you will not be able to utilize these new APIs on devices running Android 2.2 (Froyo).
You must use the regular Google Play Services library, currently at version 4.4, if you want access to Google Mobile Ads.

Google Play Service library in Android

Hello I am trying to use google-play-services_lib in my android project. As you know in android phone there is Google Play Service APK which provide a some features to you such as location fetching etc.
So I have confusion that Suppose user have Google Play Service APK version is 4.3 and I am using Google Play Services library version is 4.0.30 in android project to build the app.
Do we require same version on both side like build with same latest Google play service library and Google Play Services installed APK to make as like Push Notification, Location fetching work in this case or there is no link between them ?
Thanks in advance
They don't have to match.
The development of the library and the application is not completely dependant, that's why thier version number is different. As far as I know, each release of the services apk defines a maximum version of the library that is supported. So the only conflict could happen when the services apk is outdated (on the target device), and your application's library is a newer one.
The best you can do is to update the library, and the services application on your device.
It should work that way.
I dont think so that there is link between APK and supported libraries in that because the APK silently gets updated about libraries

How to bundle services with android project

I'm trying to use google maps in my android application. Therefore, I have 2 projects. One is my android app and another will be the google-play-services. How can I export the apk so that it is bundled together with the google-play-services?
Unfortunately, I don't think it's possible to bundle the actual Google Play services APK as part of your app. From the official docs:
To test your app when using the Google Play services SDK, you must use either:
A compatible Android device that runs Android 2.3 or higher and
includes Google Play Store. Or...
The Android emulator with an AVD that runs
the Google APIs platform based on Android 4.2.2 or higher.
You can, however, check if Google Play services are available and do an action based on the result (in your case, link them to the store where they can download it) by calling isGooglePlayServicesAvailable() as described here.

Google Play Service , Using Updated Google Map V2

i am using google play services in my project, i am trying to use google map v2 service in my app.
For this i included play services as dependency in build.gradle file as mentioned in this thread.
for now the latest version of play services is 3.2.65 and i am pointing to it. Ok.
So my question is ,In the future when google releases newer version of play services and the device has play services version above 3.2.65 which was specified in build.gradle file, will cause any problem or not? And will my application adapts the latest feature of play services automatically or i have to release updates of my application every time google releases newer version of play services.
And if not then is there any other way or including play services in module dependency so that my application will always use updated version of play services.
Thanks
My guess is you have to recompile your project with a newer version of the library.
Various library versions are downloaded on your machine and used to compile the project.
SDK_DIRECTORY/extras/google/m2repository/com/google/android/gms
Of course Google releases things in order to preserve compatibility, so if you don't need any new feature/API you don't have to update your project.
In your build.gradle file, you can also write in this way:
compile 'com.google.android.gms:play-services:3.1.+'
So you will pick up any new 3.1.x version whatever is the latest number.
In the future when google releases newer version of play services and the device has play services version above 3.2.65 which was specified in build.gradle file, will cause any problem or not?
No, it won't cause any problems. Google Maps Android API v2 is developed in a forward-compatible way. No change will ever be made that can break older apps.
And will my application adapts the latest feature of play services automatically or i have to release updates of my application every time google releases newer version of play services.
Depends. Most of the bug fixes are made in the Google Play Services app and you don't need to update client library. Because client library has almost no code, there is low chance any bug will appear there.
If you want to use new features, you will obviously have to update the library to be able to call new APIs.

Categories

Resources