Copy example files into TeamCode
Pages 1 to 3 send you here. Do these steps, then go back.
The example files are in the library. Your robot’s code must be in TeamCode. You copy the files,
then change a few lines so that they belong to TeamCode.
On this page, <example> is the name of the folder you copy, for example gobildabot. Put the real
name there, without the < >.
1. Copy the files
Section titled “1. Copy the files”- In Android Studio’s Project panel, pick Project in the menu at the top of the panel (not Android). Why: the Android view does not show the library’s examples.
- Open
ftc-helper-lib/examples/src/main/java/com/crossbotics/ftchelper/examples/<example>/. - Select every
.javafile in it. Copy them (Ctrl+C, Mac: Cmd+C). - Open
TeamCode/src/main/java/org/firstinspires/ftc/teamcode/. Right-clickteamcodeand pick Paste. Android Studio may show a Copy box: press OK. - Right-click
teamcode, pick New > Package. Typeautosafter theteamcode.that is already there. - Copy every file from the example’s
autosfolder into your newautosfolder the same way.
2. Change the package lines
Section titled “2. Change the package lines”The first line of each file is its package line. It must name the folder that the file is in now:
| File | Its first line |
|---|---|
next to Robot.java |
package org.firstinspires.ftc.teamcode; |
in autos |
package org.firstinspires.ftc.teamcode.autos; |
Before:
package com.crossbotics.ftchelper.examples.gobildabot;After:
package org.firstinspires.ftc.teamcode;Android Studio may have changed some of them for you when you pasted. Check every file.
Why: a file whose package line does not match its folder does not build.
3. Change the imports
Section titled “3. Change the imports”The files in autos import Robot, and some import Actions. Those imports still name
the example folder. Change each one to org.firstinspires.ftc.teamcode.
Before:
import com.crossbotics.ftchelper.examples.gobildabot.Robot;After:
import org.firstinspires.ftc.teamcode.Robot;Do the same in every file that has an import com.crossbotics.ftchelper.examples line.
Android Studio marks each line it cannot find in red.
4. Delete the @Disabled lines
Section titled “4. Delete the @Disabled lines”Some example OpModes have this line above the class:
@Disabledand this import:
import com.qualcomm.robotcore.eventloop.opmode.Disabled;Delete both, in every file that has them: Controls.java, each autonomous, and each finder.
Why: @Disabled hides an OpMode on the Driver Station. The examples use it, so they do not fill
the list. Your copies must show.
5. Change the OpMode names
Section titled “5. Change the OpMode names”In Controls.java, find @TeleOp(name = "..."). In each autonomous, find
@Autonomous(name = "...", preselectTeleOp = "..."). Change the names to your own.
group = "Examples": change it to your own group, or delete it. Leave group = "Finders" on the
finder files: the docs look for the finders in that group.
preselectTeleOp must be the TeleOp’s name, exactly. Why: after the autonomous, the Driver
Station picks that TeleOp for you.
Done when
Section titled “Done when”- No
packageorimportline namescom.crossbotics.ftchelper.examples. - No
@Disabledline is left. - Build > Make Project ends with no red errors.
Next: go back to your start page: a starter bot, a common setup, or a blank slate.
Look it up: Search every class and method and Troubleshooting: build problems.
Something wrong on this page? Tell us with a short GitHub form.