简体   繁体   English

Intellij始终给出未解决的符号

[英]Intellij consistently giving unresolved symbol

I have several kotlin projects, all following intellijs default gradle structure. 我有几个kotlin项目,所有项目都遵循intellijs的默认gradle结构。 A couple of them are library projects, and a couple of them are applications. 其中有两个是图书馆项目,有两个是应用程序。 I normally depend on the libraries from the applications by building the librarys as jars, adding them to C:\\lib, and then depending on them from my application code, with 通常,我通过将库构建为jar并将其添加到C:\\ lib,然后根据我的应用程序代码中的依赖来依赖应用程序中的库

 flatDir{
     dirs 'C:\lib'
 }

listed as a repository. 列为存储库。 This has always worked great for me. 这对我一直很有效。 Suddenly in the last day or so, it has ceased to work: the application code still compiles and runs fine, but when I view code in the editor it won't give autcompletes and all references to any of my library code is marked as an unresolved reference. 在最后一天左右突然停止工作:应用程序代码仍然可以编译并且可以正常运行,但是当我在编辑器中查看代码时,它不会给出autcompletes,并且对我的任何库代码的所有引用都标记为未解决的参考。 This issue is only present for code from my own libraries which I am depending on in this manner: references to ie guava have no problems. 这个问题仅存在于我自己依赖的库中的代码中,我以这种方式依赖它:对guava的引用没有问题。

I have tried everything I can think of: rebuilding the artifacts, invalidating caches and restarting, deleting the .idea folders and reimporting, deleting the projects and making new ones with the same code, restarting the computer, restoring old versions of the .idea folders which I happened to have, and nothing has solved the problem. 我已经尝试了所有我能想到的一切:重建工件,使缓存无效并重新启动,删除.idea文件夹并重新导入,删除项目并使用相同的代码制作新项目,重新启动计算机,恢复.idea文件夹的旧版本。我碰巧遇到的问题,没有任何解决方案。

I can't write any new code until this problem resolves. 在此问题解决之前,我无法编写任何新代码。 My workflow is a bit janky, but I have been using it for a long time and am very happy with it, so I'm super hesitant to abandon it. 我的工作流程有些混乱,但是我已经使用了很长时间,并且对此感到非常满意,因此我非常犹豫放弃它。 That said, if nothing else works I'd be open to suggestions of a better way to handle the whole setup. 就是说,如果没有其他效果,我会提出更好的方法来处理整个设置的建议。

Note: It occurs to me that the first relevant question would be what has changed when it broke. 注意:我想到的第一个相关问题是,当它破裂时发生了什么变化。 As far as I am aware, nothing. 据我所知,什么都没有。 The library code was recompiled right before everything broke, but I recompile it close to once a day and have never had such an issue before, and I can't think of any other change that would have prompted the issue. 库代码在一切崩溃之前就已经重新编译了,但是我几乎每天都重新编译一次,而且之前从未遇到过这样的问题,而且我想不出其他任何会引起问题的更改。

I solved the problem by doing all of the following at the same time. 我通过同时执行以下所有操作解决了该问题。 I tried all of them individually and none worked, so its hard to say which ones were necessary and which just happened to be part of the attempt that finally worked, or whether it was all just random chance. 我单独尝试了所有这些,但没有一个起作用,因此很难说哪些是必要的,哪些恰好是最终成功的尝试的一部分,或者这是否仅仅是随机的机会。

  1. Invalidate caches and close intellij. 使缓存无效并关闭intellij。
  2. Delete intellij config folder. 删除intellij配置文件夹。
  3. Uninstall intellij. 卸载intellij。
  4. Delete the .idea folder from all the projects. 从所有项目中删除.idea文件夹。
  5. Restart the computer. 重新启动计算机。
  6. Download intellij again, install it, and set it to use 4gb of ram. 再次下载intellij,进行安装,并将其设置为使用4gb的ram。
  7. Reimport all the projects. 重新导入所有项目。
  8. Publish the jars to my local maven repository instead of using the flatdirs approach I had been using before (Thanks @Moira , not sure if this was part of the fix but it still seems a better setup) 将罐子发布到我的本地Maven存储库中,而不是使用以前使用过的flatdirs方法(感谢@Moira ,不确定这是否是修复程序的一部分,但它似乎仍然是更好的设置)

edit Nevermind. 编辑 Nevermind。 This fixed the issue for a couple days and then it regressed randomly. 此问题修复了几天,然后随机回归。 So frustrated. 好沮丧

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM