Java program no longer sees WPI libraries

I left VS Code, not having any problems at all, after having imported an Eclipse project. After restarting my computer, I open up VS Code again and all of my imports have the squiggly red underline underneath the edu portion of them. When I hover over it, I see the error “The import edu cannot be resolved”. Additionally, the NavX library I just installed is also underlined at “com.kauailabs”.

What could’ve happened, and how can I fix this?

you may need to rerun gradlew build in the command line to refresh your gradle build and make sure you’re connected to the internet

There’s a VS Code action you can run that might fix this, after running a build:

ctrl-shift-p, type “java”, and look for one that says something like “clean workspace”

1 Like

I ended up copying and pasting my code into a new file. This fixed all the FRC functions that wouldn’t import. This did not fix the NavX library, however.

you may need to rerun gradlew build in the command line to refresh your gradle build and make sure you’re connected to the internet

Whenever I run the gradlew batch file, I’m shown a command line screen which promptly removes itself from my screen, and it didn’t fix my issue.

ctrl-shift-p, type “java”, and look for one that says something like “clean workspace”

I tried this as well, and it did not fix the problem.

I had this problem an hour or so ago. I was cleaning my repository and put .classpath on the gitignore.

Whoops.

Yes, .classpath and .project, along with the .settings folder need to be git ignored, because they contain system specific settings. The default templates include these in the ignored items.

wait, so classpath should go in the gitignore? Because then it got deleted when i cleaned the repo and that broke the imports.

Yes. The extension uses that for internal configuration, and its not the same across computers.

My .classpath is in the gitignore, as are .project and .settings. Same issue

Hmm. Only NavX? The WPILib code now works? Ok, Right click on your build.gradle and run Update Project Configuration and see if that helps.

The WPILib code works fine after I copy-pasted it into a new project. The NavX still did not work after this.

I right-clicked build.gradle and ran Update Project Configuration and nothing was fixed.

Ok, so if navx doesn’t work in that new project, did you install navx into that project? Vendor libraries are not automatically shared between projects, they have to be installed into each project.

How can I accomplish this? I ran the setup file in the folder I downloaded from NavX.

After that, you then have to use Manage Vendor Libraries to install it into your project. Their instructions say how to do this.

1 Like

Got it working. Thank you so much, I didn’t know I needed to do that.

So to summarize…
.classpath, .project, and .settings should not be in gitignore?

No, they NEED to be in .gitignore. you do not want them in source control

but when i put them in gitignore, i couldn’t even build because i didn’t have the classpath and that broke the imports.

That should not be the case. When you open the project in vscode, it regenerates them. You do need them on the local system, but you don’t want them on git.

I figured it out. I cleaned the repo and that got rid of it