Reverse Geocoding SDK not working?

Hello, I implemented a reverse geocoding call for some points while planning a route, when today I tried to run my app it just crashed on a null value exception, that comes from a variable that it is expecting the SDK response. The only way I come to realise the issue was making a synchronous call (that always retrieves com.tomtom.sdk.search.common.error.SearchFailure$NetworkFailure@“some id here”), because the asynchronous call is also not working properly, the “onFailure” void is never triggered.

I verified the api key and it is working with the Reverse Geocoding API explorer. I also tried changing the code from Java to Kotlin, but it produces the same error even with the page tutorial example.

Thanks in advance.

Can you share the code that is causing this?
Which SDK version are you using?

Hi, I used this code with Java but I also tried the same code in Kotlin, as I mentioned even the page tutorial will throw the same error:

private ReverseGeocoderResponse markerLocationData (GeoPoint location)
    {
        final ReverseGeocoderResponse[] result = {null};
        
        ReverseGeocoder r = OnlineReverseGeocoder.create(getApplicationContext(), BuildConfig.CREDENTIALS_KEY, null, null);
        ReverseGeocoderOptions options = new GeocodeResponse().setOptions(location);
        
        r.reverseGeocode(options, new ReverseGeocoderCallback() {
            @Override
            public void onSuccess(ReverseGeocoderResponse reverseGeocoderResponse) {              
                result[0] = reverseGeocoderResponse;
            }

            @Override
            public void onFailure(SearchFailure searchFailure) {
                System.out.println(searchFailure);
            }
        });
        return result[0];
    }

Please ignore the class GeocodeResponse(), I am just calling a Kotlin class to create ReverseGeocoderOptions with the specified Geopoint needed to obtain the location data.

Though I ended sorting this problem making a direct call to the API and formatting the Json response.
Edit: It is worth mentioning the “onFailure” callback was not being triggered at any point, as stated in my previous message.

Also I tried two versions of the SDK, 0.22.4 and 0.12.0.

Just tried Reverse Geocoding with SDK version 0.12.0 and it works in my app.
I assume we would need full project to investigate this.

Hello, thanks for taking your time checking it, since the map feature is just part of the whole app functionality I doubt the project can be shared. I am going to investigate this further since the issue is kind of circumvented now.
I created a new project and confirmed that the reverse call works as you say, I will double check the other project and if I come with a clue of what is going wrong I will post the update here for further reference.

So I finally tracked down the issue, the reverse geocoding callback method is working, the problem is the callback gets basically lost, because it never returns during the current execution of the code in the main thread. By this I mean, the project executes a function (lets say “load_Geopoints”), in the main thread, inside of that function the reverse geocoding function is called, the callback has a delay so the function just ends returning null as result.
So far I tried two things, implementing part of the code inside the onSuccess void from the callback and adding a CountDownLatch to the reverse geocoding function; here comes the issue where I am probably missing something, no matter where you place the code or how much you wait for the callback response, it just won’t happen during the main function (load_Geopoints), it will only trigger after the main thread has finished executing its code.