Android Studio“无法解析符号"但是项目可以编译和运行 [英] Android Studio "cannot resolve symbol" but project compiles and works
问题描述
项目编译正常.但是,Android Studio 3.0.1用红色显示了对一个特定库的引用,并显示无法解析符号".即使单步进入该库模块也不起作用.
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 that library module doesn't work.
我已经尝试过各种选项,例如1)使缓存/重新启动无效2)删除构建目录3)清理并重新构建,但似乎没有任何效果.
I already tried various options like 1) Invalidate cache/restart 2) deleted build directory 3) clean and rebuild but nothing seems to be working.
有趣的是,当Android Studio在无效/重新启动后重建索引时,它会暂时显示库引用在,但再次以红色显示.
Interestingly, when Android Studio is rebuilding indexes after invalidate/restart, it momentarily shows that library references in while but then again in red.
推荐答案
我尝试了Invalidate cache/restart
或clean Project -> rebuild project
.这些对我不起作用.
I tried Invalidate cache/restart
or clean Project -> rebuild project
. These didn't work for me.
最终的解决方案是打开IDE左侧的项目"窗口,在项目"模式下,删除.gradle
和.idea
文件夹,然后进行同步,即可使用.
The final solution was open Project window on the left side of IDE, under Project mode, delete .gradle
and .idea
folder, then sync, it works.
这篇关于Android Studio“无法解析符号"但是项目可以编译和运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!