Could not find com.android.tools.build:gradle:2.2.0 -here is the solution

In case You had problem with:

Error:Could not find com.android.tools.build:gradle:2.2.0.
Searched in the following locations:
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom
    https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar
Required by:
    :YOUR_PROJECT:unspecified

Don’t forget modify root build.gradle and add

jcenter()

It would look like this:

buildscript {
    repositories {

jcenter()

        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
    }
}

Example gradle with incrementing version (based on commits count)

Just an example how use commits count value as a build number of app.

buildscript {
    //...
}

repositories {
    //...
}

def cmd = ‘git rev-list –all –count’ def gitVersion = cmd.execute().text.trim().toInteger() println “=== Building version ” + gitVersion.toString()

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        //...

versionCode gitVersion versionName “1.0.” + gitVersion

    }

    lintOptions {
        abortOnError false
    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }

    signingConfigs {
        release {
            //...
        }
    }

    productFlavors {
        play {
            //...
        }
    }
}

dependencies {
    //...
}

Gradlew – how speed up building (green run)

This is my solution how to speed up building gradle processes without running it in console.

There are two steps:

1. adding option to run parallel and offline

2. don’t allow download new versions using libs (especially when you build few times per minute – it is not necessary to check every time).

So first go to Android Studio settings page, and then to:

Build, Execution, Deplyoment > Build Tools > Compiler

and paste into

Command-line Options

this

--parallel --offline

Zrzut ekranu 2015-09-21 09.42.48

Next step, go to:

Build, Execution, Deplyoment > Build Tools > Gradle

and check <pre>aaa</pre>

Offline work

option.
Zrzut ekranu 2015-09-21 09.46.43

Difference will beĀ  noticeable.