Failing to deploy the code

  • Unhandled exception instantiating robot edu.wpi.first.wpilibj.I2C java.lang.NullPointerException

  • Error at frc.robot.Robot.(Robot.java:47): Unhandled exception instantiating robot edu.wpi.first.wpilibj.I2C java.lang.NullPointerException

  • at edu.wpi.first.wpilibj.I2C.(I2C.java:48)

  • at frc.robot.Robot.(Robot.java:47)

This means nothing without the rest of your code. Post a github link (or any way to get to your code) and the full error message. Also, be more specific when this error is seen.

Ok will do

We can provide a little bit of help without seeing your code - namely, how to understand what this error message means. The Error at frc.robot.Robot.(Robot.java:47) means that the unhandled exception occurred while executing code on line 47 of Robot.java, so you can start by looking for the problem on line 47 of Robot.java.

The NullPointerException means that you tried to use a property or method of an object without first creating that object.

For example, this code:
Timer tmr;
tmr.start();
will generate a Null exception error when executing tmr.start() because tmr is still set to null when you try to access the start() method.

However this code:
Timer tmr = new Timer();
tmr.start();
Or this code:
Timer tmr;
tmr = new Timer();
tmr.start();
Will not generate an execption, because tmr now is a valid Timer object, rather than being null.

1 Like

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