Unable to create instance of class com.google.maps.GeocodingApi$Response. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.
Hello, I have a problem running my Java Spring Boot application with a native image.
When searching for an address I get the error:
Unable to create instance of class com.google.maps.GeocodingApi$Response. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.
The error only occurs when compiling with native image, when using JVM the problem does not occur.
Spring Boot: 3.0.6 GraalVM: 22.3.1 JDK: 17
If you would like to upvote the priority of this issue, please comment below or react with :+1: so we can see what is popular when we triage.
@joaorodrigo Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:
- Check the issue tracker - bugs and feature requests for Google Maps Platform APIs and SDKs
- Open a support case - Get 1:1 support in Cloud Console.
- Discord - chat with other developers
-
StackOverflow - use the
google-mapstag
This is an automated message, feel free to ignore.
Having the same issue with NearbySearchRequest:
Unable to create instance of class com.google.maps.NearbySearchRequest$Response. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.
There is a similar behaviour while using TimeZoneApi with Quarkus native images, we need to add annotation RegisterForReflection, but the inner Reponse class is not public, so not able to make it work. Changing the inner class Response to public will solve the issue.
threw an exception: java.lang.RuntimeException: Unable to create instance of class com.google.maps.TimeZoneApi$Response. Registering an InstanceCreator or a TypeAdapter for this type, or adding a no-args constructor may fix this problem.