2

I created an Android mobile app that uses Google Maps API to generate a simple map and put a marker on it.

Everything works great in the Android Simulator, however when I use the Android Device, the mapView.getMapAsync does not trigger my OnMapReadyCallback().

Another thing I noted is that I am getting these messages, not sure if they are related to the problem. I tried to update everything in my SDK but these messages just don't go away:

04-07 20:36:30.990 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date.  Requires 10298000 but found 9879448
04-07 20:36:30.992 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date.  Requires 10298000 but found 9879448
04-07 20:36:30.993 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date.  Requires 10298000 but found 9879448
04-07 20:36:30.994 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date.  Requires 10298000 but found 9879448

Would you know why? My code is below...

Code:

mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(GoogleMap googleMap) {
        map = googleMap;
        map.addMarker(new MarkerOptions()
        .position(new LatLng(asset.latitude, asset.longitude))
        .title(asset.networkAssetCode));
        map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(asset.latitude, asset.longitude), 17));

        lastSeenTextView.setText("Last seen: " + asset.datetime);

        try {

            r.getLocationFromCoordinates(asset.latitude, asset.longitude, new Callback() {
                @Override public void onFailure(Call call, IOException e) {
                    e.printStackTrace();
                }

                @Override public void onResponse(Call call, Response response) throws IOException {
                    try (final ResponseBody responseBody = response.body()) {
                        if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);

                        Headers responseHeaders = response.headers();
                        for (int i = 0, size = responseHeaders.size(); i < size; i++) {
                            System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
                        }

                        final String result = responseBody.string();
                        Log.i("BiTrack", "Google Reverse Geolocation\n" + result);

                        try {

                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {

                                    Json j = new Json();

                                    updateMapView(j.getAddressFromGeolocationCoordinates(result));

                                }
                            });

                            } catch (Exception e) {

                            e.printStackTrace();

                        }
                    }
                }
            });

            } catch (Exception e) {

            e.printStackTrace();

        }

    }
});
user1060551
  • 421
  • 2
  • 11
  • 20

1 Answers1

2

I could fix the issue by adding a piece of code I found in another question here:

GooglePlayServicesUtil: Google Play services out of date. Requires 5089000 but found 5077534

private boolean checkPlayServices() {
        GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
        int result = googleAPI.isGooglePlayServicesAvailable(getContext());
        if(result != ConnectionResult.SUCCESS) {
            if(googleAPI.isUserResolvableError(result)) {
                googleAPI.getErrorDialog(getActivity(), result,
                        PLAY_SERVICES_RESOLUTION_REQUEST).show();
            }

            return false;
        }

        return true;
    }
Community
  • 1
  • 1
user1060551
  • 421
  • 2
  • 11
  • 20
  • The question and answer were very useful for me thanks to the note: "04-07 20:36:30.990 10487-10487/it.bitrack.fabio.bitrack W/GooglePlayServicesUtil: Google Play services out of date. Requires 10298000 but found 9879448" – Sergey Apr 19 '18 at 19:16