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

有帮助吗?

解决方案

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:

  1. create a library cache command: "gradle build -g ./gradle-libs". This will download all the required libraries in the folder "gradle-libs".
  2. Then, in the offline compile: "gradle build --offline -g ./gradle-libs"
  1. List item

Definitely YES, you can always install Android Studio with all SDK packages & Tools on an Off-line PC. As I just did it myself.

Only thing U have to insure that you must have one PC with internet with Similar configuration as of Off-line PC(s).For example, if you have Win 7 64bit On-Line PC, then you should have Win 7 64 bit on Off-Line Pcs as well. But I have not tried extensively on 64 vs 32 bit PCs.

Once You have installed Android Bundle (available on android studio website), on both On-line and Off-line PCs, you downland all necessary files required to run the Android Studio properly on On-Line PC.

After that, compare the folder inside sdk folder: "C:\user\name\AppData\Local\Android\sdk " available on both PCs (On-Line & Off-Line). And where ever you feel that some files are missing copy that folder from On-Line PC and paste in Off-Line Pc.Especially, you need to do this for folder : 'extras', 'tool' & 'system-images'.

After this, just ENJOY!!!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top