Tuesday, December 29, 2015

Gradle thinks 2.10 is lower than current version

Ok, so it is a bug? Yes, well simply set the gradle plugin version located in build.gradle
to greater or equals to 1.5.0. Ah! So you want to upgrade your gradle to current version 2.10
as this article being write. You could check out my gradle-upgrade-manually.

Which is going to be very fun and interesting.

Gradle Update Manually

Yup, i am using Debian 8 x64. Installing gradle with `apt-get install` gives me gradle version 1.5.
The project i have been doing requires version 2.2. Humm,  ok just download 2.10 from
https://services.gradle.org/distributions, copy and unzip into /opt/gradle-2.10

$ sudo chmod 777 /opt
$ wget https://services.gradle.org/distributions/gradle-2.10-all.zip
$ unzip gradle-2.10-all.zip

I rename the /usr/bin/gradle to
$ sudo mv /usr/bin/gradle /usr/bin/gradle-old

Append my ~/.bashrc with
export PATH=$PATH:/opt/android/platform/android-sdk-21/tools:/opt/android/platform/android-sdk-21/platform-tools:/opt/gradle-2.10/bin

Modify my android project gradle-wrapper.properties to

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=file:///opt/gradle-2.10/gradle-2.10-all.zip

Modify build.gradle to use gradle plugin at least 1.5.0 since older than that
will complain that 2.10 is lower than required 2.2

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

Then you are all set to compile and go :D