Search code examples
androidgoogle-play-servicesandroid-fusedlocation

Getting CurrentLocation 0 using fused location when google play service is different in app and device


I am trying to get Current location using Fusedlocationservice.

In my gradle file i have put below playservice version

compile 'com.google.android.gms:play-services:9.4.0'

Now if in device have latest version of google playservice then its work well. it give proper location.

But if device have lower version then its not give current location.

Its also give warning in logcat like below:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9452000 but found 6184738

So its mandatory to have latest version of playservice in device to get current location..?

If yes then i need alternet solution for this. because every user not able to update service in device so.

my code you can see here .Get Current Location 0 in marshmallow where below 23 API its give exact current Location using fused Location

Any Help will highly appreciated.


Solution

  • I have put google play service version to 7.3 in gradle instead of latest version.

    Because every user not have latest version of play service so if you put latest version of play service in application it always take null location if device have lower version play service. else user have to update play service to match application play service version.

    So I have put lower version of playservice in app. build so its supports in each device which have equal or higher version.

    got reference from doc. https://developers.google.com/android/guides/setup#ensure_devices_have_the_google_play_services_apk