zz Android Studio --“Cannot resolve symbol” 解决办法

 he symptom of this problem is usually that the build works fine from the command line (which means your build.gradle file is set up right) but you get syntax highlighting errors in the IDE. The solution is to click the Sync Project with Gradle Files button in the toolbar. We realize it's less than ideal that the IDE can't just take care of itself instead of for

Android Studio 无法识别同一个 package 里的其他类,将其显示为红色,但是 compile 没有问题。鼠标放上去后显示 “Cannot resolve symbol XXX”,重启 Android Studio,重新 sync gradle,Clean build 都没有用。

多半是因为 Android Studio 之前发生了错误,某些 setting 出了问题。解决方法如下:

点击菜单中的 “File” -> “Invalidate Caches / Restart”,然后点击对话框中的 “Invalidate and Restart”,清空 cache 并且重启。语法就会正确的高亮了。

posted on 2018-04-19 12:01  oyl  阅读(596)  评论(0编辑  收藏  举报

导航