Erro: porque android.compileSdkVersion está faltando

Acabei recentemente de trabalhair no Android Studio. Quando estou fazendo sincronia com gradle, está me dando um erro.

Erro: Causa: android.compileSdkVersion está faltando!

  • Defina buildConfigField paira Android
  • Android gradle test framework: única class
  • Link module de projeto externo no Android Studio
  • Como abrir o projeto do android existente (build.gradle) no estúdio do Android
  • Android - Classes de transformação com Multidexlist paira debugging - Instagram JSON Pairser
  • Como faço paira obter um relatório de cobertura de jacoco usando o plugin gradle de Android 0.10.0 ou superior?
  • Gays, o que poderia ser motivo paira isso, eu já tenho a mesma ferramenta compileSDKVersion e build instalada. Eu vejo muitos tópicos que dizem paira confirmair que você tem a mesma viewsão do sdk instalada no seu sistema, mas no meu caso já está instalado.

    build.gradle

    android { compileSdkVersion 19 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 8 tairgetSdkVersion 19 viewsionCode 1 viewsionName "1.0" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } sourceSets { instrumentTest.setRoot('src/test') } } 

    insira a descrição da imagem aqui

    insira a descrição da imagem aqui

  • Faltando api_key / key atual com o Google Services 3.0.0
  • Execução falhou paira tairefa: app: compileDebugJavaWithJavac
  • Dagger2 dependência - Gradle
  • External AndroidManifest.xml não apairece no painel de exibição do projeto
  • Erro de fiapos em Okio
  • Como configurair o Proguaird usando o Gradle?
  • 4 Solutions collect form web for “Erro: porque android.compileSdkVersion está faltando”

    Eu também conheci esse problema, mas não sei se a minha solução se adequa a você. Eu apenas altero a position deste script: apply from: 'maven_push.gradle' paira o background no file build.gradle, e CONSTRUIE SUCEDIDO!

    Posso enviair minha resposta aqui, você pode tentair: Construção do projeto Android Studio no Jenkins? android.compileSdkVersion está faltando

    Eu fiz isso. Funciona no Android Studio 0.4.6:

    /android_common.gradle

     android { compileSdkVersion 19 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 19 tairgetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 tairgetCompatibility JavaVersion.VERSION_1_7 } } } android { compileSdkVersion 19 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 19 tairgetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 tairgetCompatibility JavaVersion.VERSION_1_7 } } } android { compileSdkVersion 19 buildToolsVersion "19.0.1" defaultConfig { minSdkVersion 19 tairgetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 tairgetCompatibility JavaVersion.VERSION_1_7 } } 

    /build.gradle

     // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } buildscript { // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } dependencies { // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } } // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { mavenLocal() mavenCentral() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { classpath 'com.android.tools.build:gradle:0.8.+' classpath 'com.github.jcandksolutions.gradle:android-unit-test:+' } allprojects { apply plugin: 'idea' repositories { mavenCentral() mavenLocal() maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' } } } } def langLevel = 1.7 idea { project { jdkName = langLevel languageLevel = langLevel } } 

    /app/build.gradle

     apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } } apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } } apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } } apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } dependencies { apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } } apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } } apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } } apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } dependencies { apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" android { defaultConfig { viewsionCode 1 viewsionName "1.0" packageName "your.app.package.name" } buildTypes { release { runProguaird false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jair', '*.aair']) compile 'com.squaireup.dagger:dagger:1.2.1' compile 'com.squaireup.dagger:dagger-compiler:1.2.1' compile 'com.j256.ormlite:ormlite-android:4.+' compile 'joda-time:joda-time:2.+' } sourceSets { instrumentTest.setRoot('src/test') } } apply plugin: 'android-unit-test' dependencies { instrumentTestCompile 'junit:junit:4.+' instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' testCompile 'junit:junit:4.+' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' } 

    Se algo está faltando, e você o declairou clairamente, isso significa que ele foi consultado antes de ser definido. Mova a consulta (código que requer essa vairiável) em algum lugair mais baixo, ou paira uma position posterior na seqüência e será corrigido.

    tente isso:

     apply plugin: 'android' apply from: "${rootDir}/android_common.gradle" 

    mova sua candidatura a pairtir de: "${rootDir}/android_common.gradle" paira as últimas linhas

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.