Timor Gruber
Timor Gruber

Reputation: 332

Configuring gradle completely offline

So I have a PC at work which can't be connected to the internet by any means, and it should be a developing PC for android apps, preferably using gradle. I'm using IntelliJ IDEA as my IDE (Same as Android Studio) and I know gradle has an option for offline work.
However, ticking the offline box didn't help as the gradle was not distributed locally - And so I've managed to install a local distribution of the latest gradle version.
But even this isn't enough as it fails to sync AGAIN, only this time it says it it can't a cached version which is available for offline mode.

After reading a bit on the subject, I've found out that the most common solution to this problem is to let Gradle connect to the internet the first time a project builds, so it will get its' required dependencies and stuff, and then you can switch it back to offline.

Problem is: I can't have any connection to the internet, not even for a brief moment or some proxy servers or whatsoever.

Can I somehow manage to distribute Gradle completely offline?

Upvotes: 1

Views: 1615

Answers (2)

Timor Gruber
Timor Gruber

Reputation: 332

It occurs that only configuring and copying the cache from an online machine to the offline one as @BenjaminMuscko suggested isn't enough.

It is also very important that the bits of the operating systems will match and that the cache's folder full path will be exactly the same on both machines, which means that it must be configured for identical user names! (At least on windows).

For Example:

Say we have a 32bit offline machine running Windows, and our active user name is Test, we must by all means have exactly the same configurations on the online machine in order for this technique to work - which means the the online machine should also run Windows 32bit and have its' active user named Test.

Upvotes: 0

Benjamin Muschko
Benjamin Muschko

Reputation: 33466

The only option you have is to check out the project on another machine that does have internet access, resolve all dependencies so you have them in the cache (~/.gradle/caches) and then copy the cache directory to the machine that does not have internet access. From thereon Gradle has all dependencies required for your project. Don't forget to run Gradle with --offline.

Alternatively, you could copy of all required JAR files to a specific directory which you reference as flat directory repository.

Upvotes: 2

Related Questions