最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

okhttp - Android Studio cannot resolve symbol OkHttpClient - Stack Overflow

programmeradmin1浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default -1

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

发布评论

评论列表(0)

  1. 暂无评论