Android Studio “cannot resolve symbol” but project compiles and works

后端 未结 13 2168
我在风中等你
我在风中等你 2020-12-24 10:49

The project compiles fine. However, Android studio 3.0.1 shows reference to one particular library in red and displays \"cannot resolve symbol\". Even single stepping into

相关标签:
13条回答
  • 2020-12-24 11:15

    This has happened to me a couple of times, there are a few ways you can resolve this problem;

    1. Sync project files with gradle in the File toolbar
    2. Use the Invalidate/Restart option in the File toolbar to invalidate the caches.
    3. Delete the .idea folder and restart Android Studio
    0 讨论(0)
  • 2020-12-24 11:16

    For me problem was that AS suggested I upgrade gradle version, (from 3.5 to 4.4), and then it started doing it.

    Solution was to delete the 3.5 folder from .gradle in project

    0 讨论(0)
  • 2020-12-24 11:18

    None of the answers worked for me

    Fixed it by:

    1. Removing & adding all java files via Project window on the left side of Android Studio

    2. Commenting/un-commenting & syncing libraries in the gradle file in small groups.

    And cleaning all caches before that (as part of other fixes here).

    0 讨论(0)
  • 2020-12-24 11:19

    Following has resolved this for me.

    1. remove library from gradle cache (in case of linux, it's in ~/.gradle/caches).
    2. remove library dependency from the build.gradle and sync
    3. restart (maybe invalidate cache)
    4. add library dependency to build.gradle and sync
    5. clean and rebuild
    0 讨论(0)
  • 2020-12-24 11:24

    Tried all of the above but nothing worked.

    Got Solution by: 1. Updating Android studio to latest version 2. Updating the Gradle version to latest one

    0 讨论(0)
  • 2020-12-24 11:26

    I've tried Invalidate Caches/Restart..., tried manually delete .idea and .build folders and it didn't work for my case. I using VCS (git) and I just commit my changes, removed the whole project, and Checkout from Version Control. It fixed this problem.

    Android Studio 3.6.3

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