Gradle builds fail when no network present if + present in the version

I have been building a gradle project with Android Studio for many weeks which uses this:

dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'

I was trying to work on an airplane offline, and it failed with the error message included at the bottom of this big report.

If I change the classpath to use 0.12.2 instead of 0.12.+, it works without an error message. I could understand this failing if my laptop was using a clean Android Studio install. But if I toggle the network on to do a build, it works, and then toggle the wifi off, it fails.

So it seems like the + rule is requiring the ability to check an update server. When it really should try to check, and if it fails, then it should just use whatever is stored locally and build with that. I believe the bug is in gradle and not in Android Studio itself, and would appreciate any assistance with this.

ERROR MESSAGE:

+ ./gradlew :mobile:assembleRelease
Error listing versions of com.android.tools.build:gradle using class org.gradle.api.internal.artifacts.repositories.resolver.MavenVersionLister$1. Will attempt an alternate way to list versions. This behaviour has been deprecated and is scheduled to be removed in Gradle 2.0
  FAILURE: Build failed with an exception.
  * What went wrong:
A problem occurred configuring root project 'android-glider'.
- Show quoted text -
   > Could not resolve com.android.tools.build:gradle:0.12.+.
     Required by:
         :android-glider:unspecified
      > Failed to list versions for com.android.tools.build:gradle.
         > Could not list versions using M2 pattern 'http://jcenter.bintray.com/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'.
            > Could not GET 'http://jcenter.bintray.com/com/android/tools/build/gradle/'.
               > jcenter.bintray.com

I am using the following Android Studio which includes gradle: Android Studio (Beta) 0.8.6 Build #AI-135.1339820, built on August 8, 2014 Platform: OSX

1 Like

Did you try to run this with the ‘–offline’ command line parameter?

1 Like

Ah, thanks. The --offline command line parameter worked for me.

It just seems strange that it requires online access in order to complete the build like this, when all the dependencies are in place.