7

I've got two Ubuntu 16.04 machines. One is connected to the Internet, while the other one is fully offline. I'd like to build an Android project on the offline machine. On the online machine, it builds successfully. So, I've copied the entire .gradle to the offline machine and run build process with --offline flag. Surprisingly it fails. Lots of

No cached version of ....

I suspect it's because of the hash algorithm used to generate hash for each .jar, .pom, etc. I think hashes are different from one machine to another machine. Also note that my username and machine name are different in this two. It looks like hashes are related to the username. Am I right? Is there a clean solution to get the project built on the offline machine?

  • Gradle 4.0-bin
  • com.android.tools.build 2.3.0
frogatto
  • 28,539
  • 11
  • 83
  • 129
  • Solution: https://discuss.gradle.org/t/how-to-copy-gradle-caches-to-another-offline-machine/23413/2?u=abforce – frogatto Oct 05 '17 at 17:45

2 Answers2

0

There are a couple of directories that you can copy over to the offline machine:

$HOME/.gradle
$HOME/.android
$HOME/.m2

Along with the entire project that you have built. That will have a local .gradle directory as well.

Also make sure you have the android sdk m2 repo installed or make sure that you copy over the m2 repo for the support library found at "https://maven.google.com"

Ray Hunter
  • 15,137
  • 5
  • 53
  • 51
  • There's no `.m2` directory, but there are only `.gradle` and `.android`. Copied both of them, still it keeps giving the same error. – frogatto Jul 24 '17 at 04:16
  • @HiI'mFrogatto are you copying over the entire project too? – Ray Hunter Jul 24 '17 at 04:21
  • Yes, entire project directory including that `.gradle`. – frogatto Jul 24 '17 at 04:41
  • I think those hash strings are the main culprit. – frogatto Jul 24 '17 at 04:42
  • @HiI'mFrogatto they could be and you are sure you do not have an `$HOME/.m2` directory? Those hashes should be md5 so they should be good to transfer over. – Ray Hunter Jul 24 '17 at 06:05
  • I double checked now. There's no such directory indeed. – frogatto Jul 24 '17 at 06:21
  • Regarding hashes, md5 of what? – frogatto Jul 24 '17 at 06:22
  • Sorry it is the shasum of the file. For example this path: ~/.gradle/caches/modules-2/files-2.1/com.firebase/firebase-jobdispatcher-with-gcm-dep/0.5.2/63526b3c8b9638c21e9ced2f3b2963cde9d3c286 that hash is a shasum of the file firebase-jobdispatcher-with-gcm-dep-0.5.2.aar So that should be the same for what you have. – Ray Hunter Jul 24 '17 at 06:30
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/149959/discussion-between-ray-hunter-and-hi-im-frogatto). – Ray Hunter Jul 24 '17 at 06:31
0

As per the official documentation, since at least version 6.1 of Gradle, it's possible to copy over the cache from the path $GRADLE_HOME/caches/modules-<version> to another machine for reuse. The only note is that the *.lock and gc.properties files from this directory should be skipped.

Prectron
  • 282
  • 2
  • 11