How to resolve Google Play Services library dependency with minimum required version - android

I am trying to include a SMS feature from Google play services support libraries to improve the authentication process. The documentation around it recommends using atleast minimum of 10.2 play services in order to use it.
Prerequisites:
The SMS Retriever API is available only on Android devices with Play services version 10.2 and newer.
However, when I go to build my project specifying the 10.2.0 version of in gradle, Android studio tells me it is unable to resolve this dependency from either jcenter or google's repos.
compile 'com.google.android.gms:play-services-auth-api-phone:10.2.0'
Error:org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.google.android.gms:play-services-auth-api-phone:10.2.0.
I tried searching for the package, but couldn't find that version: google's maven repos only show 11.0 and above.
It would be really helpful if someone could point me to the minimum available version of play services libraries over 10.2 that can be used to make this work.

Versions of Google Play services prior to 11.0.0 are only available through the SDK Manager. Make sure you have installed the Google Play services item in the SDK Tools tab of the SDK Manager.
However, in the case of the SmsReceiverClient API, that class was only added in Google Play services 11.0.0 SDK. It may be that the underlying implementation did exist back to 10.2, but was not public.
In any case, Google Play services releases an SDK only after it is made available to all users and will automatically update the vast majority (99.5%+) of users within the first week or two of availability. Given that 11.0.0 has been available for over 6 months, it should not be any issue in relying on the 11.0.0 library.

Related

Unable to Get Latest Google Play Services - Google API for Android

My problem is simple but I am not able to resolve it.
I have updated latest version of Android Studio and my Android SDK Manager[Screen Shot Attached] says that I have latest version of Google Repository but actually I don't have the latest versions installed. I only have Google Play Services version 11.0.4 on my machine in Android SDK Folder but its not latest version, the latest version has reached to 11.8.0 mentioned Here.
I have tried everything but I am not able to download the latest version and I need help please.
Please tell me how can I download the latest version of Google APIs for Android.
You don't need to use Google Play Services from the SDK Manager. It is recommended to use your gradle build.xml to get it from Google's maven repository. See the setup guide
If you are developing on Unity there are many plugins you can use, just Google Search for "Google Play Services Unity".

How to compile an app with older Google Play Services dependencies while using newer SDK

Let's say in our project we go back in Git to a previous app version with older Google Play Services in build.gradle file and we have newer versions of Google Play Services SDK installed on our computers. So in that case, compiling either fails or succeeds but resulting app-crash in the first Google Play Services related operation.
For example the current crash message I am dealing with is starts like that:
java.lang.NoSuchMethodError: No static method zzax(Z)V in class
Lcom/google/android/gms/common/internal/c; or its super classes
(declaration of 'com.google.android.gms.common.internal.c'
and it points to this line:
GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
My question is, how one can compile an Android app with older Google Play Services dependencies while using newer SDK in it's computer?
Note:
I believe downgrading the SDK is not an option because the SDK manager doesn't show the obsolete version (while it does show for other components).
Thanks for your help.

"This app won't run unless you update Google Play Services" when app is installed on real device

When I install my app on Android devices running older versions (for example 4.4.4), I get this message. All the other posts I can see relating to this message seem to be when running on the emulator and related to Google Maps API. I am using Google Play Service 7.0.0.
This android developer's blog entry describes what's new in the version 7.0 of Google Play services.
If you don't need those you're good to go with version 6.5 which already uses new GoogleApiClient class and provides granular dependency modules (best described here and here.
In one of my projects i use this
compile 'com.google.android.gms:play-services:6.5.87'
It's the whole package and I'll pick only the modules I need before deployment. Works fine against target API 22.
The farthest version I'd go with would be
compile 'com.google.android.gms:play-services:6.1.71'
This one introduced the unified GoogleApiClient approach used today.
So should I use an older SDK?
Absolutely not, this is not an SDK related problem. Keep everything (build tools, compile SDK, target SDK) to 22.
is there a better way to handle this than asking my users to update their Google Play Services?
See above, use older version of the library with your project.
"This app won't run unless you update Google Play Services" when app is installed on real device
You get this message on your phone because your device has low version of google play service compared to the one used in the app.
Updating it, will work properly

Maximizing Google Play Services Backwards Compatibility

What are the recommended practices for maintaining the widest backwards compatibility of an Android app while depending on Google Play Services?
The developer implementation documentation for using Android Studio indicate compiling against v5.+
compile 'com.google.android.gms:play-services:5.+' which with the available downloads I'm using seem to end up using version 5208000. At which point I get errors and warnings returned while testing an application:
W/GooglePlayServicesUtil Google Play services out of date. Requires 5208000 but found 5089036
E/GooglePlayServicesUtil GooglePlayServices not available due to error 2
Admob, my dependency on Google Play Services, appears to work normally however. If you follow the Google recommendation to call isGooglePlayServicesAvailable() and GooglePlayServicesUtil.getErrorDialog(), the user is told an upgrade is required for the app to work and sent to the store where there is no update available.
In other places maintaining backwards compatibility means compiling against the oldest API version that supports the features you need. So I tried with v4 compile 'com.google.android.gms:play-services:4.+' which generated another error:
E/GooglePlayServicesUtil﹕ The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
Searching around indicates this is a false report and can be ignored.
If I compile against a newer API version and it's not present on the device will things work? Or do I have to coax users into upgrading? Is it better to compile against an older API version and assume that things are properly backwards compatible with newer versions running on devices?
I'm the developer of an SDK that optionally depends on Google Play Services, and my approach has been, as you mentioned, to compile against the oldest version of Google Play Services that contains the APIs that I need, such that downstream clients won't into issues like these.
If the APIs that you need are available in v4, it's safe to compile against com.google.android.gms:play-services:4.+, and to follow Google's directions to show a prompt to a user to upgrade. Users will only see the upgrade dialog if they're running an older version of v4, or if they're somehow still on v3. In either case, the upgrade dialog should correctly lead them to the Play Store, where there will indeed be an upgrade available.
If the APIs that you need are only available in v5, do not use a wildcard version (ie 5.+). You should compile against an older version that is likely to be widespread, such as com.google.android.gms:play-services:5.0.89. Using a wildcard means you'll compile against the very latest version of Google Play Services that you've installed in the Android SDK manager, on whatever computer/environment you happen to be compiling on, which to me just feels wrong - I don't care if it's Google building the library, I like to know exactly what I'm compiling into my app.
Moreover, with a wildcard, if you always keep your SDK manager updated, whenever you compile the release version of your app and then push it to Google Play, you may have just shipped an app against a version of Play Services that isn't widespread, or worse - isn't even available for download on every device yet, in which case users will get the dialog and not be able to upgrade, as you've seen during development.

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