1

I am trying to compile project via command line without internet connection. I never ran the project assembleRelease via cmd before so I do not have cached version of the gradle and hence I receive the error:

No cached version of com.android.tools.build:gradle3.0.1: available for offline mode

What I assume I need to do is (go where no one has gone before) copy cashed version of the gradle from android studio (in there assembleRelease runs just fine). But I got confused in within those folders. I have gradle folder in AndroidStudio folder with m2repository and gradle-4.1 Then also folder in C:\Users\ACAndroid.gradle with caches folder and other folders. The last folder is .gradle in my project with 4.1 folder, wrapper and etc.

So what is the correlation between these 3 gradle folders and what I need to copy where in order to run the project via cmd. Also when running in --offline --debug I can see it searches the ACAndroid folder.

Dim
  • 4,527
  • 15
  • 80
  • 139
  • Once your synced, you can work offline. – Jon Goodwin May 21 '18 at 10:01
  • How I get it to sync without internet? – Dim May 22 '18 at 07:13
  • First, you need to sync your project with internet connection available to cache libraries then you could work offline. Check the answer below in https://stackoverflow.com/a/24106285/6176003 – Paraskevas Ntsounos May 23 '18 at 10:30
  • This is the explanation how to work offline in android studio. As I said it works just fine, so the cached is saved somewhere. But I run via cmd and apparently the cache is somewhere else. But where? – Dim May 23 '18 at 12:29

1 Answers1

1

Here's what you need to do: (On windows: if you don't have the Gradle version cached yet)

  1. Download the latest version of gradle (or any version that suits you from https://gradle.org/releases) (Be sure that you download the binary unless you need the sources)
  2. Now unzip this in a suitable directory (for me I've got it saved to C:\Android\Gradle)
  3. Now run sysdm.cpl by pressing Windows + R
  4. Now click on the Advanced tab and then click on the Environment Variables button: sysdm.cpl Dialog Window

  5. Now click on Path under System Variables (to access globally) or user (to only make it available on your user account)

  6. Finally add a new location under the path and add the location to the gradle distribution /bin directory
  7. Now you can run Gradle from anywhere

If you already have it cached, then it should be somewhere here (unless you have determined to save gradle to a different location):

%USERPROFILE%\.gradle\wrapper\dists\gradle-x.x-all\

Now simply add this to path, and now you've made this accessible globally. But be sure to only add the bin directory as only then will you be able to access the binary executable! Adding applications to the path makes life way simpler!

For more information with adding environment variables, see this: https://www.java.com/en/download/help/path.xml (It's a similar scenario like yours)