You Should Know About Gradle Offline Mode

If your team uses Android Studio to develop robot controller code, there are some changes with how various components are delivered this season – which might leave you with an unpleasant surprise at your next competition.

With the Freight Frenzy season’s release of the FTC SDK, the core libraries are no longer shipped as part of the GitHub repository – they are only referenced in the Gradle build file, and downloaded on demand (which is pretty standard):

repositories {
    mavenCentral()
    google() // Needed for androidx
    jcenter()  // Needed for tensorflow-lite
    flatDir {
        dirs rootProject.file('libs')
    }
}

dependencies {
    implementation 'org.firstinspires.ftc:Inspection:7.0.0'
    implementation 'org.firstinspires.ftc:Blocks:7.0.0'
    implementation 'org.firstinspires.ftc:Tfod:7.0.0'
    implementation 'org.firstinspires.ftc:RobotCore:7.0.0'
    implementation 'org.firstinspires.ftc:RobotServer:7.0.0'
    implementation 'org.firstinspires.ftc:OnBotJava:7.0.0'
    implementation 'org.firstinspires.ftc:Hardware:7.0.0'
    implementation 'org.firstinspires.ftc:FtcCommon:7.0.0'
    implementation 'org.tensorflow:tensorflow-lite-task-vision:0.2.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'org.firstinspires.ftc:gameAssets-FreightFrenzy:1.0.0'
}

Your robot controller code might also access other libraries, like our very own TntFtcCore, or EasyOpenCV which will also be downloaded by Gradle during the build process. Gradle itself attempts to check and download new versions of itself while building as well.

However, this can cause an issue when you are attempting to build after changing your robot source code while at a location with little to no network access to the Internet – somewhere like an FTC event.

Android Studio has an off-line mode for Gradle builds to deal with this situation, but you have to know where to enable it, and you need to do at least one build with your current dependency requirements while you have access to the internet before you are able to build off-line.

To enable the offline mode, you need to open the “Gradle” tab on the right side of Android Studio:

Next, you’ll need to toggle Offline mode, which is in the upper-left side of the Gradle window:

While still connected to the internet, perform a build. I like to then test that this all worked by disabling the WiFi, and building again – which should succeed. Once this is all working – it should be possible to change robot controller code without access to the internet. However, our team always does a build with internet access, and a test build without before we travel to events.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close