6

I have no internet connection. I want to use android studio but it gives me Gradle sync errors every time I try to use it.

Is there a way to run android studio without internet?

Note that I have SDK and JDK running well.

Cant resolve jUnit error

My java codes are not resolved too. Java methods error

Ali.Rashidi
  • 1,284
  • 4
  • 22
  • 51

3 Answers3

4

Download the latest gradle file from here. Then in your Android Studio goto File->Settings->Build,Execution,...->Build Tools->Gradle. Then In the right side Check the "Use local gradle distribution" and then set the downloaded file as your gradle home. Below, in the Global gradle settings check the Offline Work option.->Click Ok.
DONE

But Even though doing this will let you create a simple android app, you won't be able to import any external libs.

Akhil Soman
  • 2,077
  • 2
  • 17
  • 30
3

For Android Studio 2.3.0.8 (2/Mar/2017):

  1. Goto File->Settings->Build->Gradle, check "Use local gradle distribution" and change "Gradle home" to: [android-studio-path]\gradle\gradle-3.2 or whatever version there, and check "Offline Work" option there.
  2. Degrade the targeted gradle version of the project\build.gradle (not the app\build.gradle) like that (it was 2.3.0):

    dependencies { classpath 'com.android.tools.build:gradle:2.2.0' }

  3. Goto File->Project Structure->Modules->Dependencies, remove all but:

    {include=[*.jar], dir=libs} com.android.support.appcompat-v7:23.3.0 com.android.support.constraint:constraint-layout:1.0.0-alpha7

  4. Sync.


  • Be aware that the tricky IDE disables "Offline Work" option without notification, so you need to:

  • Firewall those or it will download without notification:

[android-studio-path]\jre\bin\java.exe [android-studio-path]\bin\studio64.exe|studio.exe

captain_majid
  • 140
  • 13
  • Unfortunately google disabled this solution in Android Studio 2.3.1 (4/4/2017), so I'm going to stick with 2.3.0.8, nice eye.. goo. keep watching. – captain_majid Apr 12 '17 at 11:17
0

Another way is to add local dependencies for JUnit with jar files

https://github.com/junit-team/junit4/wiki/Download-and-Install

Download both files and copy them to your app/libs directory

And modify your build.gradle file as follow:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.3.0'
}
Kusan
  • 260
  • 1
  • 11