Run time error on Rio

We are getting an error at runtime: “java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.”

Everything I see on here says this is related to running unit tests, we are not doing anything with unit tests, absolutely nothing. We have no references to junit in any of our code.

There was one post that mentioned making sure we installed wpilibs using the installer, we’ve done that. Another mentions making sure to upgrade the project to 2020. We created the project with the 2020 libs installed so that is all set.

We have formatted the Rio to version 2020_v10 about 10 times.

Please give us the full error. There are additional lines that contain more information

  • Last Load Error:
  • no wpiHaljni in java.library.path: [/usr/local/frc/third-party/lib]
  • at edu.wpi.first.wpiutil.RuntimeLoader.loadLibrary(RuntimeLoader.java:84)
  • at edu.wpi.first.hal.JNIWrapper.(JNIWrapper.java:38)
  • at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:316)
  • at frc.robot.Main.main(Main.java:29)
  • Info roboRIO: Game data update “RRR” received by Robot
  • java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
  • attempted to load for platform /linux/athena/

Please post your build.gradle

It won’t let me attach it, so here it is. As a side note, I tried to run the latest WPILib installer, but it keeps putting the files in wpilib/2020 instead of frc2020. I tried to manually copy the files over and that didn’t help. Nor could I pick what directory it would install to.

plugins {
id “java”
id “edu.wpi.first.GradleRIO” version “2020.3.2”
}

def ROBOT_MAIN_CLASS = “frc.robot.Main”

// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO’s backing project EmbeddedTools.
deploy {
targets {
roboRIO(“roborio”) {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = frc.getTeamNumber()
}
}
artifacts {
frcJavaArtifact(‘frcJava’) {
targets << “roborio”
// Debug can be overridden by command line, for use with VSCode
debug = frc.getDebugOrDefault(false)
}
// Built in artifact to deploy arbitrary files to the roboRIO.
fileTreeArtifact(‘frcStaticFileDeploy’) {
// The directory below is the local directory to deploy
files = fileTree(dir: ‘src/main/deploy’)
// Deploy to RoboRIO target, into /home/lvuser/deploy
targets << “roborio”
directory = ‘/home/lvuser/deploy’
}
}
}

// Set this to true to enable desktop support.
def includeDesktopSupport = false

// Maven central needed for JUnit
repositories {
mavenCentral()
}

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
dependencies {
compile wpi.deps.wpilib()
compile wpi.deps.vendor.java()
nativeZip wpi.deps.vendor.jni(wpi.platforms.roborio)
nativeDesktopZip wpi.deps.vendor.jni(wpi.platforms.desktop)
testCompile ‘junit:junit:4.12’
}

// Setting up my Jar File. In this case, adding all libraries into the main jar (‘fat jar’)
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
}

Per https://docs.wpilib.org/en/latest/docs/getting-started/getting-started-frc-control-system/wpilib-setup.html it is supposed to be installed to wpilib/2020

Your build.gradle looks like it was created as a 2019 project and the version changed to 2020. This is exactly what causes the issue you’re having. You need to use 2020 vscode to create the project or import the old project. https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/importing-gradle-project.html

That fixed it. What I don’t understand is why I need to install an entirely new version of the IDE instead of just importing the extension and libraries into the IDE I already had installed. That’s what I’d done, I didn’t edit the build.grindle. It was generated when i create the project in VS 2019 with the new libs and extensions installed.

Thanks for your help and patience!!

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