Android Studio is running on version 2.2.2 with gradle 3.2.1 and gradle plugin 2.2.2
I am working on a project migration from Eclipse ADT to Android Studio. My Android Studio project has multiple ADT projects imported as modules. Android Studio runs in offline mode, gradle sources are available locally.
Top level build.gradle
apply plugin: 'com.android.application'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
* What went wrong:
A problem occurred configuring root project 'My-Project'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.2.
> No cached version of com.android.tools.build:gradle:2.2.2 available for offline mode.
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I needed to get sure the path to the gradle cache has been defined and it is the same for Android Studio and the console build.
The easiest way is to define path to gradle home:
I created a dummy project on a computer with internet access, executed a gradle online sync. After that, switched into offline mode in Android Studio and executed
./gradlew --offline in the project folder. Build was successful.
Now, it is possible to create a new project still in offline mode (internet access can be switched off) and use the cached gradle build.