This question already has answers here:
updating Google play services in Emulator
(12 answers)
Closed 4 years ago.
I'm developing an application with android studio and i use an emulated android device to test it. The emulated device is Nexus 4 with Android 4.4 (with google apis).
In my project, i use the lastest play service client version, the 9.2.0:
When i launch my app on emulator, following message appeare:
The question is: how can i upgrade play service on emulator? Tnx
Just add Google Play Services to you project. To make the Google Play Services API's available to your app, add a new build rule under dependencies for the latest version of play-services.
Open the build.gradle file inside your application module directory.
apply plugin: 'com.android.application'
...
dependencies {
compile 'com.google.android.gms:play-services:9.2.0'
}
Be sure you update this version number each time Google Play services is updated.
As described in the Google Play services overview, Google Play delivers service updates for users on Android 2.3 and higher through the Google Play Store app. However, updates might not reach all users immediately, so your app should verify the version available before attempting to perform API transactions.
Because each app uses Google Play services differently, it's up to you decide the appropriate place in your app to verify the Google Play services version. For example, if Google Play services is required for your app at all times, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can check the version only once the user navigates to that portion of your app.
You are strongly encouraged to use the GoogleApiClient class to access Google Play services features. This approach allows you to attach an OnConnectionFailedListener object to your client. To detect if the device has the appropriate version of the Google Play services APK, implement the onConnectionFailed() callback method. If the connection fails due to a missing or out-of-date version of the Google Play APK, the callback receives an error code such as SERVICE_MISSING,
Related
I am using android studio and already added
compile 'com.google.android.gms:play-services:8.1.0'
in dependencies.
I am using min sdk version 10 and normally api 10 is preloaded with play services v4.0.27.
so is there is any other way to use feature of play services v8.1.0 features without updating it in device?
so is there is any other way to use feature of play services v8.1.0 features without updating it in device?
No.
I updated one of my apps a few months ago to version 8.3.0 of Google Play services, and that version broke backwards compatibility for some location related APIs.
So my question is, if my device already had Google Play services 8.3.0 installed even when I was running my app using version 6.5.87, how is it possible that it was still working? (Given that the APIs on 6.5.87 are no longer available on 8.3.0) Do devices keep older versions of Google Play services to support backwards compatibility? Or are the removed APIs somehow available on the installed version of Google Play services and hidden on the library shared with developers?
What I'm trying to understand here is if updating Google Play services on my app actually brings background improvements to the app (like using the latest algorithms in the library), or if those improvements are already available as soon as the device installs the new Google Play services version.
EDIT:
After looking into this in more detail I saw that no APIs were actually broke, however some interfaces were converted into abstract classes (see https://developers.google.com/android/guides/releases#september_2015_-_v81) and that is what caused the compilation issues I had back then.
The issue I had happened because version 8.1 of Google Play services was no longer compatible with older versions (because of the change mentioned above), so all the libraries I was using had to be built with 8.1+, if one of them was built with an older version then the compilation failed with this error:
java.lang.IncompatibleClassChangeError: The method 'boolean com.google.android.gms.common.api.GoogleApiClient.isConnected()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
EDIT 2:
Even though the issue I faced was not about removed APIs, I found an example of an API that was removed on Google Play services version 7: GooglePlayServicesClient (see Cannot resolve symbol 'GooglePlayServicesClient').
In the release notes of of Google Play Services 8.3 I don't see any note on API calls not available anymore. My guess is that the calls are just deprecated and not removed.
its not automatically available for your app
when update Google play service version you must have to update your app with new version of Google play service code only then your app have new algorithm
if your app have old version of Google play service & device have new version: don't worry your app works fine because your app already have Google play service code in your APK.(device don't keep old version code of Google Play service when update to new one).
if your app have new version of Google play service & device have old: then you must have to ask user update Google play service in his/her device then your app work fine in his/her device
so, its not necessary to device must have more then one version of Google Play service
EDITED: 12-01-2015
I already give you answer of this but still i w'll give you example
I have used Google play service(v 7.8.0) in my app for Location(com.google.android.gms:play-services-location:7.8.0) and for maps(com.google.android.gms:play-services-maps:7.8.0) and current Google Play service Version is 8.4.0 still my app working file why? because some of google play service code attach with my APP code see image below.
I have extract code from APK file. see Google play service code available with APK see package name com.google.android.gms that's why my app wok fine without any issue.
you can also generate your app code see this answer for more detail;
I am trying to implement google play location services in my android app. I have followed this tutorial
It does not works on some devices. The google api client does not connects. It always goes to the callback method onConnectionFailed.
I am using Android Studio and in the gradle file, I have added the following line:
compile 'com.google.android.gms:play-services-location:7.8.0'
So far I have found is that the version mentioned in the project (7.8.0) is more than the play services version installed in the device (7.5.71). So, it goes to the callback onConnectionFailed with the error code 2.
On changing the version in gradle file from 7.8.0 to 7.5.0, it works fine in these devices also.
So, is there any workaround so that I will be able to use the latest version and still be able to run it without any problem in the devices which does not have the latest version?
Google Play Services updates on its own in the background. If the device has not yet been updated to the latest version, you can show a prompt instead and ask the user to update it manually by opening Google Play Services on Google Play
I'm building an app using google map v2, it requires google play services, so I added this validation to check for it:
int checkGooglePlayServices = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(myContext);
if (checkGooglePlayServices != ConnectionResult.SUCCESS) {
// google play services is missing!!!!
/*
* Returns status code indicating whether there was an error.
* Can be one of following in ConnectionResult: SUCCESS,
* SERVICE_MISSING, SERVICE_VERSION_UPDATE_REQUIRED,
* SERVICE_DISABLED, SERVICE_INVALID.
*/
GooglePlayServicesUtil.getErrorDialog(checkGooglePlayServices,
myContext, REQUEST_CODE_RECOVER_PLAY_SERVICES).show();
}
So it turns out I have a device 4.0.4 that didn't come with google play services (why? I dont know, but it has gmail, and maps working fine), when I run the app the validation works and takes me to play store to install/update google play services, however the page says: Your device isn't compatible with this version.
So how do I install google play service if it is not available on play store?
is it common to have android devices without this app ?
thanks,
The error seems to suggest the play services version on your device is not compatible with the play services library used by your app. Where does it say the play services is not available on your device.
To make sure the play services in running on your device, and to find out its version, look in Settings -> Apps -> Downloaded -> Google Play Services
Since it is not giving you an option to update the play services on device, I would consider using a matching play services client library in your app. You can easily do this on Android studio build.gradle of the app module by adding exact version to your dependencies like so
dependencies {
compile 'com.google.android.gms:play-services:5.0.89'
}
replace 5.0.89 with the version you find on your device.
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.