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
Yes, Android Studio is meant to be used offline, unless you are using git and committing all your code changes to git. One other scenario when you need the internet is when trying to use some external library/API using gradle.
Gradle needs an internet connection to download the dependencies that you specify. Once it downloads everything, it can put them in memory so that you can work offline. To do this, you need to go to Files->Settings (For Mac: Android Studio-> Settings...). You can now build your project without internet.
Android Studio 0.4.0 added this functionality:
From the release notes:
Google is planning to bundle gradle with Android Studio, that will provide the ability to do builds offline. However, this will not be available until v0.5.0 preview release. See here for details.
In the mean time, the current workaround is to download your own gradle libs to make any builds offline. You can do it as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With