Android Studio: Cannot resolve ‘method’ and other strange odd behaviours

Scenario: You are working on the same Android Studio project on multiple computers, carrying the essential files on a pen drive, or on the cloud or whatever you want. Open the project and mysteriously some methods (more than one surely) aren’t recognized anymore, or some classes, or just variables. But the project compiles and runs fine!!! Syncing/building don’t resolve this thing.

Solution n. 1:
open that class or method, digit anywhere in the source any visible character on the keyboard and mysteriously all that class come recognized perfectly. Just open the other classes too and make the same thing. Pity for this solution don’t last about 2 minutes that other methods return unresolved…

Solution n. 2:
Invalidate cache/restart

Solution n. 3:
  • Follow this order:
  • Terminate the process java bound to Gradle, you can find it in Task Manager adding the column ‘command line’, in that column there will be something with ‘gradle’
  • In the root of the project delete the folder .idea, .gradle, eventually release and build
  • For each other folder, navigate in each of them and delete any folder like these: release, build
  • Delete also the folder .gradle contained in your root profile %USERPROFILE%
  • Finally in Android Studio, Invalidate cache/restart.

Leave a Reply

Your email address will not be published. Required fields are marked *