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?
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?
Share Improve this question asked Jan 29 at 7:33 Jeremi RedaJeremi Reda 1 2- refer stackoverflow/questions/34816171/… – Sasi Kumar Commented Jan 29 at 7:33
- Yes, I've seen this thread, and tried all the suggestions but none of them resolved the issue. – Jeremi Reda Commented Jan 29 at 17:30
1 Answer
Reset to default -1I 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