Cannont resolve symbol JSONObject (Android Studio)

2020-07-06 03:00发布

问题:

I have spent two days in this. I can work with other PC, but my Android Studio doesn´t import the library, I took two captures:

As yo can see in the first picture, Android Studio autocompletes my line:

However:

I was reading about JSONObject in Android Developers (here) and Android include this in library. I also have tried to import other libraries from "org", but just works fine two of them:

Them... I was thinking this might be a problem of Android Studio, and I reinstalled the IDE, the error persists.

And I have tried to import the library in the gradle (this is in build.gradle module: app):

I was working with other PC, it works well, but I need to fix this in my computer.

Please, any help will be grateful.

回答1:

I´ll respond to the future, if someone has the same error:

I did this (Thaks to Bigdestroyer):

File -> Invalidate caches/Restart -> Invalidate and Restart 

You can try to delete ~/.gradle/caches directory to force re-download the dependencies.

Now its works perfect. Thanks !!!!