I'm using the following code to get the direction between two points on Google Maps:
Callback<Direction> directionCallback = new Callback<Direction>() {
@Override
public void onResponse(@NonNull Call<Direction> call, @NonNull Response<Direction> response) {
if (response != null) {
if (response.isSuccessful()) {
Direction direction = response.body();
Log.d("TAG", response.raw());
if (direction != null) {
List<Route> routes = direction.routes;
if (routes.size() > 0) {
//Get first route
} else {
Log.d("TAG", "routes.size() = 0");
}
}
} else {
Log.d("TAG", response.errorBody().toString());
}
}
}
@Override
public void onFailure(@NonNull Call<Direction> call, @NonNull Throwable t) {
Log.d("TAG", t.getMessage());
}
};
directionCall.enqueue(directionCallback);
This code works perfectly fine when I run my app from Android Studio on a phone or emulator, however, when I update the app in Google Play, the body of the Retrofit call becomes empty, getting as result:
routes.size() = 0
If if log response.raw()
, I get the following response:
Response{
protocol=h2,
code=200,
message=,
url=https://maps.googleapis.com/maps/api/directions/json?origin=11.1741765%2C22.6436729&destination=11.189821%2C22.640532&mode=walking&key=LongKey
}
If I click on that link, I get the desired JSON file, but the body is empty. No error message. Does anyone know what the problem might be?