Reputation: 1
I'm trying to use OkHttpClient in Android Studio 4.1.3 and I'm getting the error "Cannot resolve symbol 'OkHttpClient'".
I've found a number of posts for this problem but none solve my issue.
I added the following line to the dependencies section of my project's build.gradle (:app) file and then clicked 'Sync now'.
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
No errors were reported by the sync operation.
I then added the following import statement to a file.
import okhttp3.OkHttpClient;
This shows as an error with the message "Cannot resolve symbol 'OkHttpClient'".
I tried adding the following line to my code.
OkHttpClient okHttpClient = new OkHttpClient();
But holding my mouse over this line does not give me an option to import a class, instead it just shows the "Cannot resolve symbol 'OkHttpClient'" message.
Is there anything else that I need to do on top of adding the dependency line to the gradle file and syncing?
Upvotes: 0
Views: 72
Reputation: 21
I don't know if you imported the package, you can check the external libraries for okhttp3, you can also try to clean up Gradle cache and re-sync, I think the biggest problem is probably version incompatibility.You can try to change the api version and then recompile the project
Upvotes: -1