Error "The import com.ctre cannot be resolved"

I’m new to command based programming and to coding talons, and we just can’t figure out why this one error keeps occurring. We’ve followed the steps for talon and phoenix installation and added vendor libraries but it just keeps returning. Any ideas?

If you correctly see Phoenix.json in your vendordeps in the project explorer then you can try rebuilding the java workspace.

CommandPalette -> java -> Clean java server workspace

1 Like

Assuming you’ve installed the offline installers for the phoenix libraries, your first step is to make sure the .json file made its way into the following folder hierarchy:
C:\Users\Public\wpilib\2020\vendordeps
Next, make sure the com.ctre.phoenix and such folders made their way into the maven folder here:
C:\Users\Public\wpilib\2020\maven
If both of those are done, uninstall your phoenix vendordep from the project, reimport it, and it should be fixed. Also, make sure you have the newest version of WPILib. Here is another description of what I just said from the FRC 3rd party libraries page:

The Mechanism - C++/Java

For C++ and Java a JSON file describing the vendor library is installed on your system to ~/wpilib/YYYY/vendordeps (where YYYY is the year and ~ is C:\Users\Public on Windows). This can either be done by an offline installer or the file can be fetched from an online location using the menu item in Visual Studio Code. This file is then used from VS Code to add to the library to each individual project. Vendor library information is managed on a per-project basis to make sure that a project is always pointing to a consistent version of a given vendor library. The libraries themselves are placed in the Maven cache at C:\Users\Public\wpilib\YYYY\maven . Vendors can place a local copy here with an offline installer (recommended) or require users to be online for an initial build to fetch the library from a remote Maven location.

The JSON file allows specification of complex libraries with multiple components (C++, Java, JNI, etc.) and also helps handle some complexities related to simulation. Vendors choosing to provide a remote URL in the JSON also enable users to check for updates from within VS Code.

Blockquote

1 Like

thank you for the thorough response! we just tried this and the error persists.

Which IDE are you using?
Once you’ve imported it, do you see the vendordep file inside your project?
image

But then some IDEs also make you do some other stuff after you’ve done that in order to recognize your dependencies

Also, have you tried rebuilding your project after importing the libs? Sometimes that helps.

The other thing you may have to try is taking every instance of CTRE Phoenix code out of your program, including the imported libraries. Next, remove all of your vendordeps by using the Manage Vendor Libraries and unchecking all of the dependencies. Then, add the dependencies back in along with all instances of CTRE code. Try to run a build at this point. Then exit VsCode and re-open your program. Sometimes VsCode will throw errors for no reason, and this is a good example of that.

The only CTRE that we could add as a vendor lib is the 5.16 even though the only one we downloaded was the 5.17

Have you installed the 2020 version of WPILib/VSCode?

The Phoenix installer for 2020 (5.17.3) is only going to place the vendordeps file where the 2020 tools can find it, while the 2019 version (5.16) will only place the vendordeps file where the 2019 tools will find it.

In that case you will have to get rid of the cached version(the 5.16 one) of the Phoenix libraries by removing them from your vendordeps and maven folders. Assuming you have correctly uninstalled FRC 2019 VsCode and have 2020, make sure 5.17 is the version you have.

We tried installing Phoenix 5.17.3.1 for Windows and it is not copying the drivers to the wpilib folders maven and vendordeps. Has anyone run into this?

Which wpilib folders are you looking at? Phoenix 5.17 and all 2020 libraries install into C:\Users\Public\wpilib\2020, and not C:\Users\Public\frc2019 like previous years. Also, VS Code 2020 will only look int the new folder, and will completely ignore the old folder. You need to make sure you are using the 2020 version of VS code with a 2020 project.

Yes we do have 2020 VSCode installed with the directory structure you mention.

Seems to be an issue with just our one laptop. It worked on another.

What’s the difference in output from “Open Project Information” from the wpilib menu between the two computers?

After a bunch of reboots it finally installed properly. I am not sure why.

I need to start another thread seeking advice on what people are doing about school issues laptops. They just changed a bunch of the restrictions.