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

3

7

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

Unity answered 23/10, 2013 at 1:58 Comment(4)
Does the order the repos are listed in matter?Goral
No, in fact the mavenLocal() was just added to try and resolve this problem without success -- I will remove it in the question since it may confuse the problemUnity
does this answer help at all?Unbridle
Nice link, but no real helpUnity
U
4

Android Studio 0.4.0 added this functionality:

From the release notes:

Unity answered 23/12, 2013 at 17:0 Comment(1)
It still doesn't work if studio thinks that project is not synchronised. Command line gradle builds offline correctlyDunham
I
2

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"
Infatuated answered 23/1, 2014 at 3:19 Comment(0)
P
0
  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!!!

Polysyndeton answered 28/10, 2015 at 6:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.