今天遇到这个问题,开始是布局出错,以为是配置问题,或者自己写的问题,在网上搜了一下,没有找到合理的解决办法。

如下图所示

cantnot find the declaration of element 'LinearLayout'报错和android studio项目没有sdk



还有这样

cantnot find the declaration of element 'LinearLayout'报错和android studio项目没有sdk


后来查配置发现没有问题,打开原来做好的项目也会出现这样的错误。于是决定新建个项目试试

cantnot find the declaration of element 'LinearLayout'报错和android studio项目没有sdk

新建项目的时候是这样子的。于是查看发现缺少SDK设置和SDK的目录,查资料发现原来是

Android Studio 插件Plugin Error找不到的问题

最后通过这样的方式解决

解决办法:

点击File下面的Settings

                                                                                      cantnot find the declaration of element 'LinearLayout'报错和android studio项目没有sdk

发现Plugins下面都是红色的 ,比如Android Support (用红色矩形标注的),我报错时点进去查看的时候这个插件就是报红的,然后点击后面的对勾√再重新打上的时候Android Studio就提示你重启,点击弹出的提示框中的按钮“restart”后发现Android Studio重启了。


cantnot find the declaration of element 'LinearLayout'报错和android studio项目没有sdk


重启之后就变好了。下图就是变好之后我再次查看的,至于为什么会出现明明有插件却不加载需要手动再选中这样的问题博主也不明白。就抛给其它高手来给答案吧。如果你有插件,就是加载不上或者加载不出来这样的问题可以这么做,但其它问题这种办法就不适用了。

相关文章:

  • 2022-12-23
  • 2021-10-26
  • 2021-11-29
  • 2022-12-23
  • 2021-07-28
  • 2021-05-06
  • 2021-07-11
猜你喜欢
  • 2022-01-18
  • 2021-12-28
  • 2021-09-21
  • 2021-09-19
  • 2021-12-27
  • 2021-06-23
  • 2021-10-19
相关资源
相似解决方案