We developed an application that uses the Google Play Services extension.
I assume that people without Google Play Services installed on their device side will not be able to use these services.
However if people does not have Google Play Services installed on their device, they probably cannot download it in the first place, because they dont have Google Play App itself.
So is it safe to assume that most people who install the app have Google Play Service installed and make a more general verification in our app for other rare cases?
For example, check if Google Play Services availability and if not installed, simply write a message and exit the app.
What is your opinion on that ?
Thanks
One of the things that can happen is that Google Play Services is present on the device, but not up to date. Or the user could have disabled Google Play Services. In both these cases connection to Google Play Services will fail, so you really have to check for it, no excuses :)
The answer can be found on Android's developers website
Important: Because it is hard to anticipate the state of each device, you must always check for a compatible Google Play services APK before you access Google Play services features. For many apps, the best time to check is during the onResume() method of the main activity.
Related
I had an android application working fine in all average smartphones, but only one client is using a custom phone from Huawei, he received this error Can't connect to google play service, and also Google Maps not working, so my question there's any way programmatically to send a request to download the missed google play service ?
You can't install Google Play Services like a normal application, since it isn't a normal application. It's actually at least 3.
It needs to be a system app (ie in /system/priv-app/) to work, and relies on certain other frameworks that can't simply be installed.
If this user is rooted, tell them to flash Google Play Services from something like OpenGApps or MicroG. Otherwise, if you need people without Google Services to use your app, you need to find another maps API that isn't from Google.
Google's instructions here say that if you want to use AdMob in your Android app via Google Play services you must ensure the user's device has the Google Play services APK installed. However, I'm having terrible trouble trying to get this working; and I've noticed that even if I uninstall the Google Play services updates on my phone (and don't bother checking if the services is available) my app is still perfectly able to retrieve and display ads! This is despite errors in LogCat like the following:
W/GooglePlayServicesUtil(26558): Google Play services out of date. Requires 4132500 but found 3159130
Presumably my phone still has the original version of Google Play services installed when it came out the factory. I'm just wondering whether I really need to check for Google Play services being available to use AdMob successfully. Right now it appears not. Please can someone tell me why I should bother having to make this check. Is it to handle case 4 at that Google link I gave above...?
The Google Play services APK is missing or disabled on the device, which might happen if the user explicitly uninstalls or disables it.
TL;DR - You do NOT need to check for Google Play services to use the Mobile Ads APIs.
The Google Mobile Ads offering in Google Play services is unique from most (all?) of the other libraries in Google Play services in that it CAN work without the service APK installed on the device.
If the APK installed on the device is a more recent version, the library will load the classes from the APK service and use these newer classes to request ads. Otherwise, the version of Google Play services that you compile in your app is sufficient to fetch ads.
The benefit here is that you effectively will always run against the latest version of the library when the device has the service installed. And in the case that your service version is older than the version you compiled your app against (ex: your example above) or in the case where there is no service on the device (ex: Kindle Fire), the library compiled with your app can still do the ad fetching, but you'll still have to pull in updates manually.
The logcat error you are getting is for either case 2 or 3.
Whether Admob craps out on case 4 is interesting. I suspect it will be ok because the old Admob classes ship with the GPS library so in worse case it could fall back to using their pathway.
We're building an app that relies on Google Cloud Messaging to recieve data. The app will be installed on several tablets, that each should collect different data from our server. When trying the register our test tablet with our GCM server-side, we get the error "Google Play Services out of date. Requires 3265100 but found 3027105".
We have not attached the device to a Google account, since our understanding was that if you are running 4.0.4 or higher you do not need this. We're running 4.2.2 on an Acer Iconia A1. We really don't want to attach an account to each tablet (could possible be hundreds of them).
How do we update Google Play Services, or do we even need it?
Thanks in advance
If you are using GCM from the google play service library yes you need a google account because google play services gets updated through the play store.
you can however not use google play services and just download the GCM library from the SDK Manager but its not going to get updated anymore so if there are any bugs or anything they wont be fixed. all the new updated will go into the Google Play Services
Google Play services is an Android library whose goal is to provide:
OAuth 2.0 authentication
Google+ sign-in
Google+ +1 button
various other goodies
If I were to use it (for instance because I want Google+ sign-in), what would happen to users whose device does not have Google Play? (Nook, Cyanogenmod, China Mobile, old devices, maybe Huawei?, etc)
QUESTION: Will my app become incompatible with such devices? Will it be displayed as compatible but then crash, or not work?
Is there a best practice to keep this in mind when using Google Play services?
GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
is deprecated!
Use:
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int code = api.isGooglePlayServicesAvailable(activity);
if (code == ConnectionResult.SUCCESS) {
// Do Your Stuff Here
} else {
AlertDialog alertDialog =
new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle).setMessage(
"You need to download Google Play Services in order to use this part of the application")
.create();
alertDialog.show();
}
If the feature from Google Play Services is essential for your app there would be no way to get your App working.
You can check if the services are enabled from within your app with GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
which returns ConnectionResult.SUCCESS if Play Services is available.
You can now try to convince the user to install it (if possible) or disable the feature that is using the service.
As the Google Play Services is not a feature declared in the manifest your app should install fine on any device but may crash later on if you are using the APIs without checking if they are available.
You can try the behaviour with the emulator. Just create an AVD without the Google APIs and put your App on it.
As others stated, your code should ideally check for Google Mobile Services. If you don't, it will crash with a java.lang.RuntimeException wrapping android.content.ActivityNotFoundException because you'll be invoking a function on a non-existing activity.
Good apps don't crash but instead spam users with notifications in all the places they rely on on play services as other answers suggested. If possible send only a single notification to users instead of spamming them with the same notification in every place you rely on play services - or close the app after a dialog explaining why it's closing.
Better apps (e.g. Signal) contain alternative logic for handling things like notifications without making play services a hard requirement.
To which degree you can make your app work without play services is almost entirely up to your use case. If you use Firebase for instance it will be very hard to make your app work without GMS.
In most cases it's possible to avoid GMS, in some cases it's maybe not the best idea (e.g. allowing users to use arbitrary location on a dating app).
Try searching for alternatives before you lock yourself in though: OpenStreetMap will work on more devices than Google Maps, it's not as complete as Google Maps in some regions though (it's good enough for picking a delivery location though).
The recommendation that you use GMS comes from Google. I'd personally recommend you to support more devices, vendors and OSs if it doesn't require doubling your code base.
If you are somehow required to use Play Services, or if you maintain a legacy app that makes calls to Play Services, then I would recommend this strategy:
On app start, check whether Play Services is available or not
If not available, redirect Play Services calls to microG
microG is an open source implementation of Google Play Services.
It lacks many features, but is under active development. Many features are still stubs.
For location services, there is also LOST, a drop-in replacement for the Google Play services location APIs.
You app might not work perfectly, but at least it is better than crashing.
Of course, the best is to NOT use Google Play Services, from the start.
If your app uses GMS features like Google Sign-In or Firebase Cloud Messaging, it won't work well on the devices that don't have GMS.
It's recommended that you use GMS if a device supports GMS; otherwise, use HMS (Huawei Mobile Services).
Please refer to the following links:
To check whether GMS is available
HMS Overview
HUAWEI Account Kit
So you can use Google+ Sign-In on the devices where GMS is available; otherwise, use HUAWEI Account Sign-In.
I have built an application that we will be selling to customers through the Google Play store.
We also have individuals in house that will support outside customers, and also use it in house. They need to have the application running on their own device. If I distribute it to them via an .apk file, can they receive updates via Google Play? Or do they have to purchase it through Google Play to receive updates?
Secondary question: Is there a better solution to distributing to internal users?
As curious myself and not having official info on this, I just did a test:
On Google Play I have an App at version 1.3.2
I've installed via ADB the version 1.3.0 on my device.
Opened Google Play > My Apps.
The update to version 1.3.2 was available.
Did the update
All seems to work normally.
So my word on this is: Yes they will receive the update (the app has to have the same signature of course).
Maybe you might just have a look on term of services if this isn't breaking any rules.
On the second question, the "better" solution may wary based on the company infrastructure which we don't know.
If the version on Google Play is identical to the version you distributed, signed with the same signature, and it is available as a free app, then Google Play can be used to update the version distributed outside of Google Play.
I received the following in an email from a member of the Google Play Team:
"The side-loaded apps used by your internal users will not receive updates from Google Play. You will need to provide them with the new APK in order for them to access the new features/functionality. This is working as intended to ensure that only users who have purchased a paid app will receive notifications and updates."
So: Paid for apps cannot be updated via Google Play if they are "side-loaded" (installed outside of Google Play).