Just Click on Build -> Rebuild Project option in your Android Studio.
But in some cases we may additionally need to, use File
-> Invalidate Cache...
and restart IDE (beside said rebuild, as something of previous “cannot resolve symbol” state may be cached).
We can auto-complete libraries because they are already built, but own project needs to be built first, and only then Android-Studio can see related resources.
#1 Rebuild is required, because Android-Studio does simply rely solely on Gradle’s build-result (without static-analysis support, at least at time of writing, 2022).
#2 Clearing cache may be required, because the previous build-result (before above rebuild) may be indexed, which may make Android Studio ignore latest Gradle build-result
(this is a very good speed optimization, but a very bad Developer-experience as well).There can sometimes be other reasons too, which is why there are many other answers posted here.