Offline install "Android plugin for Gradle" for Android Studio

I use Android Studio 3.1.2 with Gradle 4.4 on Ubuntu 16.04 and have to force Gradle to do off-line work, because when I use it normally (on-line), it takes to long to sync and fails. At first I got this error:

No cached version of available for offline mode.
Disable Gradle 'offline mode' and sync project

So I downloaded gradle-3.1.2.jar, put it in <project root>/libs/ and change build.gradle of my project to this state:

buildscript {

    repositories {
        flatDir {
            dirs 'libs'
    dependencies {
        classpath ''

allprojects {
    repositories {

Now it seems that previous error is solved but another one is raised:

Unable to load class ''.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)</li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)</li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

How I can solve this problem?


I know the normal way is working on-line, at least for the first build. But there must be a way to add it off-line. Isn’t there such way?

I don’t know if I understand you currently.
But you have to download all the plugins and dependencies first. Otherwise Gradle can’t work offline obviously. From where should Gradle take the plugins and dependencies? :smiley:

The AGP (Android Gradle Plugin) 3.0+ works only with Gradle 4.1 and up.
That is the reason why you get the second error if you use Gradle 3.1.2…

Thank you for reply.

Is there a way to see all dependencies? Also their archive addresses that Gradle tries to download? If yes, I can download them and add those to libs/ of project and probably the problem will solve.

You can run ./gradlew :app:dependencies which gives you a list of all our dependencies.
Most of them are available at jcenter (or at googles maven). There you can browse the repos to then download each of your dependencies…

If I run ./gradlew :app:dependencies it will check the dependencies tree. But is there a way to check the dependency tree of only one dependency and not all of them?

@Peterh you mean that it will display all dependencies for each configuration?
And you only want to display all dependencies for a single configuration?!

Yeah, you can do that:
./gradlew :app:dependenices --configuration [CONFIGURATION_NAME]
E.g. ./gradlew app:dependencies --configuration releaseCompileClasspath for all release compile dependencies…

Yes you are right, running gradle dependencies gives you a list of the dependencies of the selected project, broken down by configuration.

Thank you :smiley:

1 Like

@StefMa im having a problem with the new android studio 3.2.1 i just installed, it keeps showing me this error
“No Cached version of, available for offline mode”
the suggestions i have found is to uncheck the offline mode, but the PC i installed it on does not have internet so i downloaded the plugin 3.2.1 and placed on this location “C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle\3.2.1” but it keeps showing the same error, can you please tell me if there is other location where should i put this, or another way to make this work on a computer without conection? Thanks :wink: