Error : cause android.compileSdkVersion is missing

前端 未结 4 737
谎友^
谎友^ 2021-01-08 01:00

I am recently started to work on the Android Studio. When I am doing sync with gradle then it is giving me a error .

Error : Cause: android.compileSdk

相关标签:
4条回答
  • 2021-01-08 01:11

    try this :

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

    move your apply from: "${rootDir}/android_common.gradle" to last lines

    0 讨论(0)
  • 2021-01-08 01:17

    I did this. It works on Android Studio 0.4.6:

    /android_common.gradle

    android {
    compileSdkVersion 19
    buildToolsVersion "19.0.1"
    
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 19
    }
    
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility 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
    }
      }
    

    /app/build.gradle

    apply plugin: 'android'
    apply from: "${rootDir}/android_common.gradle"
    
    android {
    defaultConfig {
        versionCode 1
        versionName "1.0"
        packageName "your.app.package.name"
    }
    
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
        compile 'com.squareup.dagger:dagger:1.2.1'
        compile 'com.squareup.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'
    }
    
    0 讨论(0)
  • 2021-01-08 01:21

    If something is missing, and you have clearly declared it, it means that it was queried before it was defined. Move the query (code that requires that variable) somewhere lower, or to a later position in the sequence and it will be fixed.

    0 讨论(0)
  • 2021-01-08 01:23

    I met this problem too, but I don't know whether my solution suit for you. I just change the position of this script: apply from: 'maven_push.gradle' to the bottom in build.gradle file, and BUILD SUCCESSFUL!

    I post my answer here, you can try it.: Building Android Studio project on Jenkins? android.compileSdkVersion is missing

    0 讨论(0)
提交回复
热议问题