nyongrand
nyongrand

Reputation: 618

Android studio cannot resolve but build successfully after update

It's start after I update Android studio to version 3.1 stable, then I open my project, Android studio start to complain that can't resolve bla bla bla... (many import become red)

What I did so far :

  1. Sync gradle
  2. Clean build then rebuild
  3. Invalidate cache and restart
  4. Deleting .gradle folder in project
  5. Deleting .gradle/cache folder in user folder (i'm on Windows)
  6. Uninstall and reinstall Android studio

But so far the issue is not resolved, some things to note :

  1. I use kotlin
  2. I still can build and deploy the apk
  3. The unresolved reference seems only on library that I added on gradle
  4. If I downgrade or upgrade the library, this seems fix the problem, but when I back to the original library version the issue came back.

Upvotes: 4

Views: 2307

Answers (2)

SIRS
SIRS

Reputation: 624

I do not know if this will solve your problem, but try to open other old project so Android Studio will ask you to upgrade gradle, do, and after the sync finish, close the project then open your project.

EDIT 1: It seems, my answer will only partially fix your problem, to fully fix your project, you need to open another project then add all your library used on your problematic project, sync the project then close it, your problematic project will be fixed.

But don't ask me why this happen.

EDIT 2: Apparently, you can try deleting all library on your project, sync gradle, then clean project, after that, just add again your library then again sync gradle.

Upvotes: 3

Slava Glushenkov
Slava Glushenkov

Reputation: 1518

  1. Exit from Studio
  2. Delete .idea/, build/, app/build/ directories.
  3. Start Studio.
  4. Re-setup Settings->Build tools->Gradle to use local distribution (last stable Gradle locally installed)

Helps me.

Upvotes: 4

Related Questions