Intellij Keeps forgetting the source directories & class references on checkout
已回答
I have a gradle project and on every checkout / switch of branch, intellij keeps forgetting the directories which are marked as "sources root" & I have to select " Try to resolve class reference" for every import statement. I manually do it every time ! I already tried the below but nothing seem to work.
- Invalidate cache -> Restart IntelliJ and then resolve all the "sources root" & dependencies. Switch to a another branch !
- Resolve all the "sources root" & dependencies. File -> Manage IDE settings -> Export. -------------> Switch to another branch -------------> File -> Manage IDE settings -> Import .
.idea directory is not checked into git. I have added it to .gitignore, locally.
Intellij Ultimate Version : 2022.2.1
Please help !
请先登录再写评论。
Could you please try to update to the latest version of IntelliJ.
And check if the issue reoccurs? If yes, you can try the following:
⌘ + ,on MacOS orCtrl+Alt+Son Win/Linux) > Tools > Shared Indexes > disable 'Wait for shared indexes'. Set both 'JDKs' and 'Maven Libraries' options to 'Don't download, use local indexes'If it is still occurring, please share your IDE log file (Help > Collect Logs and Diagnostic Tools). You can upload the zip file here: https://uploads.jetbrains.com. Just provide the uploaded file ID. Thanks!
IntelliJ IDEA Updated to 2022.3.2 (Ultimate Edition) . The issue still existed, after the update. So, I've followed the other steps as mentioned & the sources directory is automatically recognized now. However, I see a couple of compilation reference issues. Even-though the methods exist, IntelliJ still complains that it cannot find it.
I'll investigate it & post back , if the issue still exists.
Thank you very much for solving the source directory issue! Project looks way better than before.
I also have the same problem. The sources root disappears after I refresh gradle.
I have 2 modules in the project. For 1 the sources root is retained, for other it is removed.
If I rename the sources folder from "kotlin" to "java", the sources are recognized again. But I don't have to rename for the first module. So it works with "kotlin" for the first one, but not for the second one. The second one I have to rename to "java"
Tonisives Please share your IDE log file (Help > Collect Logs and Diagnostic Tools). You can upload the zip file here: https://uploads.jetbrains.com. Just provide the uploaded file ID. Thanks!
Also if possible, please upload the build.gradle file content(in case it's not sensitive).
I can vote that this bug is happening for me with a multi module Maven project. Sometimes it self resolves after a project rebuild, often I have to mark them manually.
Upload id: 2023_09_01_bCQrREsUZEc7uvujVKZZQ5 (file: idea-logs-20230902-07582711519946964192751915.zip)
About info
IntelliJ IDEA 2023.2.1 (Ultimate Edition)
Build #IU-232.9559.62, built on August 23, 2023
Runtime version: 17.0.8+7-b1000.8 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.5
GC: G1 Young Generation, G1 Old Generation
Memory: 3504M
Cores: 10
Metal Rendering is ON
Registry:
ide.intellij.laf.enable.animation=true
debugger.new.tool.window.layout=true
ide.experimental.ui=true
ide.balloon.shadow.size=0
eslint.additional.file.extensions=svelte
ide.images.show.chessboard=true
Non-Bundled Plugins:
com.github.novotnyr.jwt-intellij-plugin (0.12)
net.coderazzi.aws_codeartifact_maven (3.2.2)
some.awesome (1.14)
org.intellij.plugins.hcl (232.8660.88)
com.mallowigi.idea (22.0.0)
lermitage.intellij.ilovedevtoys (1.9.0)
com.github.copilot (1.2.21.2995)
org.jraf.intellijplugin.nyantray (1.3.2)
name.kropp.intellij.makefile (232.8660.88)
org.jetbrains.plugins.go (232.9559.65)
com.intellij.nativeDebug (232.9559.34)
com.intellij.graalvm (232.9559.10)
com.atlassian.bitbucket.references (2022.1.242)
dev.blachut.svelte.lang (232.9559.10)
izhangzhihao.rainbow.brackets (2023.3.4)
zielu.gittoolbox (500.0.15+222)
org.sonarlint.idea (9.0.0.75308)
aws.toolkit (1.76-232)
com.intellij.restClient.postmanConverter (1.0.0-rc.3)
Kotlin: 232-1.9.0-IJ9559.62
Bkelly
Thank you for sharing the logs!
Similar issue is currently being investigated in IDEA-330500.
Please upvote the Issue if you are experiencing the same problem and keep track of the investigation process.