Setting Up the Android Studio Environment for FTC

What is Android Studio?

Android Studio is the official integrated development environment (IDE) for Android app development. FTC teams use it to write, test, and deploy robot code in Java. It provides advanced tools for editing, debugging, and managing your robot code, making it the preferred choice for teams with prior Java experience.

Learn more: FTC Docs: Android Studio Programming Tutorial

Why Use Android Studio for FTC?

Android Studio offers powerful features such as code completion, refactoring, integrated version control, and advanced debugging. These tools help teams write robust, maintainable code and collaborate effectively. Android Studio is recommended for advanced users with Java experience, as it provides more flexibility and control than OnBot Java or Blocks.

System Requirements

Before installing Android Studio, ensure your computer meets the minimum requirements. Android Studio requires a modern processor, at least 8GB of RAM (16GB recommended), and several gigabytes of free disk space. For the latest requirements, see the Android Studio Official Site.

Installing Android Studio

1. Download the installer from the Android Studio website.
2. Run the installer and follow the setup wizard.
3. During installation, select the default options unless your team has specific requirements.
4. After installation, launch Android Studio to complete the initial setup.
5. For a more detalied guide, see FTC Docs: Android Studio Programming Tutorial.

What is the Android SDK?

The Android Software Development Kit (SDK) provides the libraries and tools needed to build, test, and run Android apps—including FTC robot code. Without the SDK, Android Studio cannot compile or deploy your code to the Robot Controller.

Learn more: Android Studio Official Site

Why Do FTC Teams Need the SDK?

FTC robots run on Android devices, so your code must be built using the Android SDK. The SDK ensures your code is compatible with the Robot Controller app and the Android operating system. Essentially, when you push your code to the robot, you are downloading the FTCRobotController app to the Control Hub. As such, it is often helpful to physically connect your Drive Hub to your computer via USB to maintain the WiFI connection between your computer and the Control Hub.

Installing the SDK via Android Studio

When you first install Android Studio, it will prompt you to install the Android SDK. Always use the recommended settings. If you skipped this step, you can install the SDK later using the SDK Manager.

To open the SDK Manager:
  • Go to Tools > SDK Manager in Android Studio.
  • Ensure you have the correct SDK version for FTC (usually API 25 or higher, but check the FTC Docs for the latest recommendation).

Managing SDK Tools and Updates

The SDK Manager also lets you update or install additional tools. Only update the SDK if your team is sure it will not break FTC compatibility.

For more information, see Android Studio: Update the IDE and SDK Tools.

Downloading and Setting Up the FTC SDK Project

FTC teams use a special project called the FTC SDK. You can download it from the official FTC GitHub repository.

To set up the project:
  • Clone or download the repository to your computer.
  • Open Android Studio and select 'Open an existing project'.
  • Navigate to the folder where you saved the FTC SDK and open it.

High-Level Project Layout

The FTC SDK project is organized into modules and directories to separate your code from the official SDK. This structure helps you keep your code organized and makes it easier to update the SDK in the future.

For a visual overview, see FTC Docs: Android Studio Programming Tutorial.

Key Files and Directories

- FtcRobotController: Contains the official SDK code. Do not modify files here.
- TeamCode: This is where you write your own OpModes and custom classes.
- build.gradle: The build configuration file for each module.
- AndroidManifest.xml: Declares app permissions and components.
- libs/: Place any third-party libraries here if needed.

Where to Write Your Code (TeamCode vs. FtcRobotController)

Always write your OpModes and custom code in the TeamCode module. This keeps your code separate from the SDK, making it easier to update the SDK and avoid conflicts.

To create a new OpMode, add a new Java class in TeamCode/src/main/java/org/firstinspires/ftc/teamcode.

Gradle and Build System Basics

Gradle is the build system used by Android Studio. It compiles your code, manages dependencies, and packages your app for deployment. Most of the time, you won't need to edit Gradle files directly, but understanding the basics can help you troubleshoot build errors.

Learn more: Gradle User Guide

Practice Exercise: Creating Your First OpMode

Create a simple OpMode in Android Studio and deploy it to your Driver Hub.

  • Open the FTC SDK project in Android Studio
  • Navigate to TeamCode/src/main/java/org/firstinspires/ftc/teamcode
  • Create a new Java class called 'MyFirstOpMode'
  • Implement a basic LinearOpMode with telemetry output
  • Build the project and deploy to your Driver Hub
  • Test the OpMode on your robot

Additional Resources

Open full interactive app