Error : cause android.compileSdkVersion is missing - android

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.compileSdkVersion is missing!
Guys what could be reason for this, I already have same compileSDKVersion and build tool installed. I see many threads that saying to confirm that you have same sdk version installed in your system but in my case it is already installed.
build.gradle
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}

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

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'
}

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.

try this :
apply plugin: 'android'
apply from: "${rootDir}/android_common.gradle"
move your apply from: "${rootDir}/android_common.gradle"
to last lines

Related

How do I build Android project using a newer version of gradle?

I have an Android project built using gradle 1.10. I would like to build it using gradle 2.4. There are few threads where some changes are suggested which should do the job. Some users have said these changes have worked and some have not worked.
I would like to know if there is a way I can copy certain number of files and build the whole thing from scratch using Gradle 2.4?
Thanks.
It was built using Android Studio 0.5.1.
Here is Project level build.gradel:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Here is the module level build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 19
versionName "19.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Using the current Android Studio 1.3 you should use this top-level build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
The module/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion XX
buildToolsVersion "XX.X.X"
defaultConfig {
minSdkVersion 14
targetSdkVersion XX
versionCode 19
versionName "19.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:XX.X.X'
compile 'com.android.support:support-v4:XX.X.X'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Pay attention to use gradle 2.4 and change the gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer

I want to use RecyclerViewLib in my project and for that I downloaded it and imported it as a module to my empty "hello world" Android project. I am using android studio v1.0.1 using sdk manager v24 and this is my app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 17
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.example.mk.dragdrop4"
minSdkVersion 14
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
and this is my library/build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 17
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
apply from: 'https://raw.github.com/twotoasters/gradle-mvn-push/master/gradle-mvn-push.gradle'
But when I import that I'm getting this error message:
Error:No such property: GROUP for class: org.gradle.api.publication.maven.internal.ant.DefaultGroovyMavenDeployer
Can anyone help me about this problem?
Remove this line from the build.gradle on the specified project
apply from: 'https://raw.github.com/twotoasters/gradle-mvn-push/master/gradle-mvn-push.gradle'
I have experienced a very similar problem.
I tried to include the QuickReturn feature into my app : https://github.com/felipecsl/QuickReturn
I'm using Android Studios 1.0 and after I imported the library into my project, it gives me the same error. I then looked at the build.gradle file for the library and removed this line and it worked:
apply from: 'gradle-mvn-push.gradle'
Similar issue.
Removed line:
apply from: 'maven-push.gradle'
from build.gradle and was able to sync successfully.
check library and project build.gradle and comment this line if you found
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3' // include latest gradle version and if project build with older version can update or can user same version
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
}
}

Android Studio 0.5.3 android.compileSdkVersion is missing

I'm using Android studio 0.5.3
I keep getting :
Gradle 'OpenBook' project refresh failed:
Cause: android.compileSdkVersion is missing!
Gradle settings
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
sourceSets {
main {
manifest.srcFile '/MyApp/src/main/AndroidManifest.xml'
}
}
}
And My App Buid.gradle
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
sourceSets {
main {
manifest.srcFile '/src/main/AndroidManifest.xml'
}
}
}
dependencies {
// compile 'com.android.support:appcompat-v7:+'
compile project("libraries:library-toast")
compile project("libraries:Volley")
compile project("libraries:actionbarsherlock")
compile project("libraries:Dialoglibrary")
compile project("libraries:google-play-services_lib")
compile project("libraries:PullToRefreshlibrary")
compile project("libraries:facebook")
compile project("libraries:SlidingTabBarlibrary")
compile project("libraries:AndroidPlot-Core")
compile project("libraries:SignUpModule")
compile project("libraries:Jars")
compile project("libraries:UpdateChecker")
compile "com.mixpanel.android:mixpanel-android:4.0.0#aar"
}
Not Sure what to do.
Thanks for any help
You have specified "compileSdkVersion 19" in your build file. Seems like you are missing that SDK (can you post more of the output with the error in it) You need to make sure that you have installed the right SDK using the SDK manager in Android Studio.
Jake Wharton has created a new gradle plugin to automatically keep the SDKs updated https://github.com/JakeWharton/sdk-manager-plugin

Add external library into android studio 0.5.1 project

I'm using an external library SVProgressHUD in my Android studio project as a module. Everything is fine until I upgraded my Android studio to 0.5.1. It always shows the follow error message:
Error:(7, 17) package org.lcsky does not exist
Here is my settings.gradle:
include ':app',':SVProgressHUD'
My build.gradle in project folder:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
My build.gradle in SVProgressHUD module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
}
The build.gradle in my main module:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':SVProgressHUD')
}
The gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
Can anybody tell me what could be wrong? Thanks
I solved the problem by changing the build.gradle in SVProgressHUD module:
apply plugin: 'android-library'
Previously it works (before Android 0.5.1) when I set it to:
apply plugin: 'android'

Error : Gradle 'HelloWorld' project refresh failed: Build script error, unsupported Gradle DSL method found: 'setRoot()'!

Hi I am doing testing of my android app using gradle in the AndroidStudio. I am using this framework RoboLectric for doing it all.
It is giving me an error when I sync it with gradle files. Guys, share your views for this problem.
Gradle settings
3:35:14 PM Gradle 'HelloWorld' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'setRoot()'!
Possible causes could be:
- you are using Gradle version where the method is absent
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
Gradle settings
In the folder app, there is build.gradle, this is which I have right now
apply plugin: 'android'
apply plugin: 'android-test'
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
testCompile 'com.squareup:fest-android:1.0.+'
instrumentTestCompile 'junit:junit:4.10'
instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT'
instrumentTestCompile 'com.squareup:fest-android:1.0.+'
}
In the HelloWorld, there is another build.gradle where I have
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
}
}
allprojects {
repositories {
mavenCentral()
}
}
As Peter suggested in the comment to declare the sourceSets inside the android { .... }.
It worked for me.
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}

Categories

Resources