Dim
Dim

Reputation: 4827

Correlation between gradle folders

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.

Upvotes: 1

Views: 120

Answers (1)

user9050166
user9050166

Reputation:

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)

Upvotes: 1

Related Questions