Cannot access class 'okhttp3.ResponseBody'. Check your module classpath for missing or conflicting dependencies
This is my function:
fun parseError(httpException: HttpException) {
val errorBody = httpException.response()?.errorBody()
}
These are the dependencies that I have included
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("com.squareup.moshi:moshi-kotlin:1.15.0")
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-moshi:2.9.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.11.0")
This is the image as you can see there is a error below the errorBody()
Edit Answer;
I found that there is a problem in version 2.9.0 of this retrofit. It will be fixed after updating to version 2.8.2.
version.properties file
version.retrofit2=2.8.2
You can use it by doing 2.8.2.
Old Answer;
I think your project is multi module. Can you try the "api" instead of "implementation"?
I'm making this comment because I can't see more details.
The reason it cannot find related dependencies is that the dependency as reference of our project exposes third-party dependency onto its API surfaces.