okhttp - Android Studio cannot resolve symbol OkHttpClient - Stack Overflow

I'm trying to use OkHttpClient in Android Studio 4.1.3 and I'm getting the error "Cannot

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745306796a4621758.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信