androidgradleandroid-gradle-pluginbuild.gradlegradle-plugin

Different Gradle versions in my project (gradle.xml vs build.gradle)


In gradle.xml I have version 2.4 ( C:\Development\android-studio\gradle\gradle-2.4 ):

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="distributionType" value="LOCAL" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="gradleHome" value="C:\Development\android-studio\gradle\gradle-2.4" />
        <option name="gradleJvm" value="1.8" />
        <option name="modules">
          <set>
            <option value="$PROJECT_DIR$" />
            <option value="$PROJECT_DIR$/caponateLibrary" />
            <option value="$PROJECT_DIR$/launcher" />
          </set>
        </option>
      </GradleProjectSettings>
    </option>
  </component>
</project>

But in my Project uild.gradle file I have 1.3.0:

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

Why these files have different Gradle versions? Which differences does exists between these two Gradle versions and which is the real Gradle version?


Solution

  • Don't confuse gradle distribution and the android plugin for gradle.

    1) You can define the gradle distribution used by a project in the file gradle/wrapper/gradle-wrapper.properties

    For example:

    distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
    distributionUrl=http\://services.gradle.org/distributions/gradle-2.4-all.zip
    

    Each project can use a different version. You will find the distributions file inside \user\.gradle\wrapper\dists folder.

    2) Gradle is a build tool, but it requires specific plugin to work. Android Tool Team is releasing the Android plugin for Gradle.

    You can define the plugin inside the build.gradle file in the project.

    For example:

      classpath 'com.android.tools.build:gradle:1.3.1'
      classpath 'com.android.tools.build:gradle:1.5.0'
    

    Each project (or module) can use a different version.