Я интегрирую Google Места SDK для Android, и это дает мне ошибку при компиляции кода:
Ошибка : Тип com.google.android.libraries.places.internal.nx
обозначается как interface
из com.google.android.libraries.places.internal.jx$a
build.gradle
:
implementation 'com.google.android.libraries.places:places:1.1.0'
implementation 'com.google.android.libraries.places:places-compat:1.1.0'
MainActivity
:
@Override
public void onCreate() {
super.onCreate();
Places.initialize(this, getResources().getString(R.string.google_free_api_key));
InternetAvailabilityChecker.init(this);
StateSaver.setEnabledForAllActivitiesAndSupportFragments(this, true);
appExecutors = new AppExecutors();
}
private void searchPlaces(final String query){
// Create a new token for the autocomplete session. Pass this to FindAutocompletePredictionsRequest,
// and once again when the user makes a selection (for example when calling fetchPlace()).
AutocompleteSessionToken token = AutocompleteSessionToken.newInstance();
// Create a RectangularBounds object.
RectangularBounds bounds = RectangularBounds.newInstance(
new LatLng(0.703579, -82.689471),
new LatLng(-18.360459, -68.571046));
// Use the builder to create a FindAutocompletePredictionsRequest.
FindAutocompletePredictionsRequest request = FindAutocompletePredictionsRequest.builder()
// Call either setLocationBias() OR setLocationRestriction().
.setLocationBias(bounds)
//.setLocationRestriction(bounds)
.setCountry("pe")
.setTypeFilter(TypeFilter.ADDRESS)
.setSessionToken(token)
.setQuery(query)
.build();
placesClient.findAutocompletePredictions(request).addOnSuccessListener((response) -> {
List<Place.Field> placeFields = Arrays.asList(Place.Field.ID, Place.Field.NAME, Place.Field.LAT_LNG);
viewModel.getDirections().clear();
for (AutocompletePrediction prediction : response.getAutocompletePredictions()) {
Log.i(LOG_TAG, prediction.getPlaceId());
Log.i(LOG_TAG, prediction.getPrimaryText(null).toString());
FetchPlaceRequest fetchPlaceRequest = FetchPlaceRequest.builder(prediction.getPlaceId(), placeFields)
.build();
placesClient.fetchPlace(fetchPlaceRequest).addOnSuccessListener((responseFechaPlace) -> {
Place place = responseFechaPlace.getPlace();
Log.i(LOG_TAG, "Place found: " + place.getName());
viewModel.getDirections()
.add(new GeoPunto(prediction.getPrimaryText(null).toString(), "", place.getLatLng().latitude, place.getLatLng().longitude));
}).addOnFailureListener((exception) -> {
if (exception instanceof ApiException) {
ApiException apiException = (ApiException) exception;
int statusCode = apiException.getStatusCode();
// Handle error with given status code.
Log.e(LOG_TAG, "Place not found: " + exception.getMessage());
}
});
}
directionsAdapter.notifyDataSetChanged();
}).addOnFailureListener((exception) -> {
if (exception instanceof ApiException) {
ApiException apiException = (ApiException) exception;
Log.e(LOG_TAG, "Place not found: " + apiException.getStatusCode());
}
});
}