¡Obtener android.compileSdkVersion no se encuentra! error gradle build

Estoy intentando build mi biblioteca y uploadla al repository, pero desafortunadamente la compilation de gradle falla. He pasado varias horas intentando solucionar este error, pero nada de lo que probé no ayudó.
Aquí está mi build.gradle del build.gradle raíz del proyecto.

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.github.dcendents:android-maven-plugin:1.2' classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1" } } allprojects { repositories { jcenter() } } 

Y build.gradle desde mi directory de modules

 apply plugin: 'com.android.library' apply plugin: "com.jfrog.bintray" apply plugin: 'com.github.dcendents.android-maven' version = "1.0.0" android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { minSdkVersion 8 targetSdkVersion 21 versionCode 1 versionName "1.0.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } def siteUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView' // Homepage URL of the library def gitUrl = 'https://github.com/CROSP/AndroidHorizontalRecyclerView.git' // Git repository URL group = "com.github.crosp.horizontalrecyclerview" // Maven Group ID for the artifact dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'org.jsoup:jsoup:1.8.1' compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:recyclerview-v7:21.0.3' } install { repositories.mavenInstaller { // This generates POM.xml with proper parameters pom { project { packaging 'aar' // Add your description here name 'Android Horizontal Recycler View with Headerr' description = 'Android Horizontal Recycler View with Header project for displaying horizontal list on Android ' url siteUrl // Set your license licenses { license { name 'The Apache Software License, Version 2.0' url 'http://www.apache.org/licenses/LICENSE-2.0.txt' } } developers { developer { id 'crosp' name 'Alexandr Crospenko' email 'crosp@ukr.net' } } scm { connection gitUrl developerConnection gitUrl url siteUrl } } } } } task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives javadocJar archives sourcesJar } Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) // https://github.com/bintray/gradle-bintray-plugin bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = "maven" // it is the name that appears in bintray when logged name = "crosp" websiteUrl = siteUrl vcsUrl = gitUrl licenses = ["Apache-2.0"] publish = true version { gpg { sign = true //Determines whether to GPG sign the files. The default is false passphrase = properties.getProperty("bintray.gpg.password") //Optional. The passphrase for GPG signing' } // mavenCentralSync { // sync = true //Optional (true by default). Determines whether to sync the version to Maven Central. // user = properties.getProperty("bintray.oss.user") //OSS user token // password = properties.getProperty("bintray.oss.password") //OSS user password // close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually. // } } } } 

También he agregado algunas configuraciones en mi file local.properties

 sdk.dir=/home/crosp/Android/Sdk bintray.user=#### bintray.apikey=#### bintray.gpg.password=#### bintray.oss.user=#### bintray.oss.password=#### 

El problema es que recibo un error de seguimiento después de gradle bintrayUpload .

 Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence. java.lang.IllegalArgumentException: android.compileSdkVersion is missing! at com.android.build.gradle.internal.SdkHandler.initTarget(SdkHandler.java:80) 

Y al final de la salida del post de error recibo el siguiente

 * Where: Build file '/home/crosp/AndroidStudioProjects/HorizontalList/horizontalrecyclerview/build.gradle' line: 3 * What went wrong: A problem occurnetworking evaluating project ':horizontalrecyclerview'. > org/gradle/api/publication/maven/internal/DefaultMavenFactory 

Este error relacionado con la "compilation de la versión sdk" se debe a que está utilizando Gradle 2.4

Comtesting tus preferences de Android Studio y busca Gradle. Si tiene marcada la casilla "Usar distribución gradle local", consulte la versión e intente cambiar a "Usar el gradle wrapper pnetworkingeterminado (recomendado)"

Ahora si eso no funciona Verifique en la estructura de su proyecto, en la opción "Proyecto" probablemente esté usando la "Gradle versión 2.4", por lo tanto, ajústelo en 2.2.1

En el peor de los casos, tal vez estés usando tu console, así que ejecuta: gradle –version y comtesting tu versión gradle.

Intenta evitar utilizar el "Gradle 2.4" porque tiene problemas relacionados con algunas tareas en el Android Studio.