Skip to content
Advertisement

IllegalArgumentException: Unable to create @Body converter for class

Whenever I try to create a request with Retrofit it fails. The strange thing is that it worked before, I didn’t change anything about the code. Now months later it doesn’t work anymore. I’m getting the following error: IllegalArgumentException: Unable to create @Body converter for class apis.Config (parameter #2)

I tried changing from Gson to Moshi but it didn’t solve the problem. I also searched Stackoverflow and saw that people had similar problems but the solutions didn’t seem to work for me as they were mostly about duplicate SerializedNames which isn’t the case in my code.

API Service

JavaScript

Config Class

JavaScript

API Class

JavaScript

Advertisement

Answer

So I found the solution to the problem. Apparently the problem is caused by me using OpenJDK 16 certain things with reflection. I solved the issue by using the JVM parameters --illegal-access=permit when running the code. The solution is not optimal but it’s working.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement