Android Studio suddenly cannot resolve symbols

后端 未结 28 2550
南笙
南笙 2020-11-22 04:42

Android Studio 0.4.2 was working fine and today I opened it and almost everything was red and the auto-completion had stopped working. I look at the imports and AS seems to

相关标签:
28条回答
  • 2020-11-22 04:55

    I'm using Android Studio 3.1.4 and I was experiencing such issue when moving from my develop branch with a lower api target to another branch with target api Oreo. I tried the first solution which worked but it is quite tricky, while the second solution did not solve the problem.

    My Solution When the problem popped back again I have tried to modify slightly my app gradle file enough to AS to ask me to sync files, and that did the trick. Then I deleted the change.

    I guess that "Sync Project with Gradle Files" might work as well but I haven't tried it myself

    Hope it helps

    0 讨论(0)
  • 2020-11-22 04:55

    There is a far easier solution built into Android Studio, and it usually works for me without needing any brute force solution mentioned in other answers - so you should try this first:

    click on the "gradle" symbol on the right side of Android Studio, and then on the "Refresh all Gradle projects" tool.

    0 讨论(0)
  • For me it was a "progaurd" build entry in my build.gradle. I removed the entire build section, then did a re-sync and problem solved.

    0 讨论(0)
  • 2020-11-22 04:57

    I tried cleaning the project and then invalidating the cache, neither of which worked. What worked for me was to comment out all my dependencies in build.gradle (app), then sync, then uncomment the dependencies again, then sync again. Bob's your uncle.

    0 讨论(0)
  • 2020-11-22 04:59

    Go through the link and it worked for me.

    1.) Choose File option from menu on left top side of android studio.

    2.) Select the option : "Invalidate Cache/ Restart.." It will open an dialog.

    3.) Click on the first button with option : "Invalidate and Restart"

    4.) It will close the studio and restart it. Start indexing of the project.

    It resolved my problem:

    File -> Invalidate Cache/ Restart -> Invalidate and Restart

    Source: https://www.youtube.com/watch?v=FX_gCTpqhwM

    0 讨论(0)
  • 2020-11-22 04:59

    Thought i'd throw this out there too:

    the thing that worked for me was changing my build variant back to a variant that was working previously. For some reason i had changed this before (and i forgot why).

    either way, the best thing to do is to try to remember what you changed that day (it could be something as minor as cleaning, or going back to a previous git commit)...etc.

    it also helps to try to resync gradle and force a rebuild.

    0 讨论(0)
提交回复
热议问题