-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Labels
Description
Hi all,
I'd like to continue an issue than someone else started on the mapbox-jl-native repository: mapbox/mapbox-gl-native#14845
I've the same problem and the exception thrown is the following one:
java.lang.IllegalStateException: Not a JSON Array: {"type":"Point","coordinates":[1.516222,47.882982]}
at x.x.x.geocoding.MapboxGeocodingProvider$searchForDestination$$inlined$suspendCancellableCoroutine$lambda$1.onFailure(MapboxGeocodingProvider.kt:56)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$2.run(ExecutorCallAdapterFactory.java:80)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Everytime I perform a geocoding request, I got this error if the request leads to results. If no result is found for the request, then I get a correct response without exception.
This only happens in version 7.4 and 8.0. I don't have the exception in version 7.3.2. I switched multiple times between these versions and this is verified as not working only since v7.4.
Here is the implementation of my geocoding part:
suspendCancellableCoroutine<List<SearchSuggestion>> { continuation ->
val proximity = Point.fromLngLat(location.longitude, location.latitude)
val locale: Locale = LocaleListCompat.getDefault()[0]
val request = MapboxGeocoding.builder()
.autocomplete(true)
.accessToken(accessToken)
.geocodingTypes(TYPE_PLACE, TYPE_ADDRESS, TYPE_POI)
.limit(MAX_NUMBER_OF_SUGGESTIONS)
.proximity(proximity)
.languages(locale)
.query(search)
.country(ACCEPTED_COUNTRIES)
.build()
continuation.invokeOnCancellation {
request.cancelCall()
}
request.enqueueCall(object : Callback<GeocodingResponse> {
override fun onFailure(call: Call<GeocodingResponse>, t: Throwable) {
continuation.resumeWithException(t)
}
override fun onResponse(call: Call<GeocodingResponse>, response: Response<GeocodingResponse>) {
// Check if request is a success
if (!response.isSuccessful) {
if (response.code() == INVALID_TOKEN_HTTP_CODE) {
continuation.resumeWithException(MapboxTokenExpiredException("Token invalid while performing geocoding"))
return
}
continuation.resumeWithException(SearchImpossibleException("response not successful - code=${response.code()} ; message=${response.message()}"))
return
}
val suggestions = [...]
continuation.resume(suggestions)
}
})
}spiekermax and L33thaxor118