View Single Post
  #4   Spotlight this post!  
Unread 30-11-2016, 12:47
JohnMMcD JohnMMcD is offline
Registered User
AKA: John McDonnell
FTC #5873 (Dragon Terminators)
Team Role: Mentor
 
Join Date: Jul 2015
Rookie Year: 2010
Location: CT
Posts: 13
JohnMMcD is an unknown quantity at this point
Re: [FTC]: Android Studio NullPointerException on TeleOp Init

Quote:
Originally Posted by Fedoros View Post
From what I've gathered, there are many, many different problems which could give this error.
In my experience, the NullPointerException is almost always caused by invoking an object's methods before initializing the object via the hardware map. The object might be a motor, servo, sensor, etc. -- anything that gets initialized via hardwareMap.get().

I think that's your problem here, too. The code that's not in a method (lines 49-131) is running as soon at the op mode is instantiated, which is BEFORE the opmode's "init" method is invoked. Since the "init" method initializes the robot via the hardware map, any command such as "robot.driveRight.setPower(right);" will throw a NPE.
Reply With Quote