Unit testing: wpiHaljni could not be loaded from path or an embedded source

I’m currently working on a library of common robot utilities to be reused from year to year, and I would like to add unit testing to it. Some of the classes that I’m testing calls methods in WPILib which access native code (DriverStation.reportError() more specifically). While these unit tests run fine without any problems when I do a ./gradlew test on my local machine, they fail when building in Travis CI, with the error

    java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
    	attempted to load for platform /linux/x86-64/
    	at edu.wpi.first.wpiutil.RuntimeLoader.loadLibrary(RuntimeLoader.java:79)
    	at edu.wpi.first.hal.JNIWrapper.<clinit>(JNIWrapper.java:25)

(The full build log can be found here)

Is there a way I can make the unit tests work on Travis?

Unless travis has updated ubuntu on their systems (I don’t think they have) WPILib hasn’t worked on there for a few years. We require ubuntu 18.04 for linux, and theyre still on 14.04. We ended up moving all of our CI to Azure Pipelines because of this. Azure is still on 16.04, but they have trivial docker support, which is what we use on linux, or windows build just natively work. That would be my recommendation.

If you use a Windows agent, everything just works without any manual setup, and you can just run gradlew build.

Thanks! Fortunately, it seems like Travis CI has just added support for Ubuntu Bionic a couple months ago. Changing it to dist: bionic fixed the error.

1 Like

Note that will only be a likely solution for 2020. For 2021, we will potentially be switching to 20.04 LTS (we usually run on the latest LTS) and with how slow Travis is to update, I doubt they’ll add it. We will keep the docker images updated though, so those will always work.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.