How can I setup Android Studio so I can compile when offline (disconnected from the internet)

Noah picture Noah · Oct 23, 2013 · Viewed 8.6k times · Source

I was working in androidstudio today and my builds started failing. To my surprise, I had lost my internet connection and could no longer build my code.

build.gradle file contains the following:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.3'
    }
    tasks.withType(Compile) {
        options.encoding = "UTF-8"
    }
}
apply plugin: 'android-library'

dependencies {
    compile files('libs/android-support-v4.jar')
}
...

So ... how do I reconfigure my development environment, change my build.gradle and do whatever else is necessary to allow android development offline.

Note: Question edited to remove mavenLocal() from repositories, since it was added trying to solve this problem myself

Answer

Noah picture Noah · Dec 23, 2013

Android Studio 0.4.0 added this functionality:

From the release notes: