Jay Sidri
Jay Sidri

Reputation: 6406

Android Studio says "Cannot resolve method" but the project builds correctly

I've just inherited a fairly large Android codebase at work and I've come across a perplexing problem with Android/Android Studio after I've imported the project:

Opening some of the project files, I see a bunch of code highlighted in red (AS reports "Cannot resolve method XXXX"):

enter image description here

But the project builds just fine (!):

enter image description here

The methods in question do not exist AFAICS (I've done a global search for it) and yet, the project builds just fine.

I feel silly asking this but does anyone here know what's going on?

Upvotes: 0

Views: 1764

Answers (3)

Jay Sidri
Jay Sidri

Reputation: 6406

Well, it turned out the project was using Lombok and those methods were auto-generated and Android Studio does not know how to how to handle them unless you install the Lombok plugin for Android Studio.

Upvotes: 3

Richard Goodman
Richard Goodman

Reputation: 317

Have you not done a right-click on getPaymentsComponent() and chosen Go->Definition to see where it takes you ?

Upvotes: 0

user5248371
user5248371

Reputation:

Earlier I have same problem because Android Studio makes a lot of files as caches and does not delete them. This can cause trouble when there is a need to make new files, so clearing caches will clear the old cache may be it solve your problem

go to file menu and Click invalidate Caches / Restart.

Upvotes: 3

Related Questions