Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The project may be using a version of Gradle that does not contain the method 'compileSdkVersion()'

I'm facing this issue when trying to run a project originally made on Eclipse ADT.

Error:(17, 0) Gradle DSL method not found: 'compileSdkVersion()'
Possible causes:<ul><li>The project 'TaxiAndroidOpen-master' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

I already converted this to Android Studio gradle system.

But I cannot run it, nor compile it, because of this error, here's the gradle generated:

// Top-level build file where you can add configuration options common to  all sub-projects/modules.
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.0.0'
   }
}
allprojects {
repositories {
    jcenter()
   }
}

ext {
compileSdkVersion 17
buildToolsVersion '18.1.0'
}
dependencies {
}

I've found some other posts here on SO, with similar errors, but no one has this specific one.

I'm using Android Studio 1.0.2, x86.

Anybody can shed some light on this?

Thanks in advance!

EDIT

Updated build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 17
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.opentaxi.android"
    minSdkVersion 9
    targetSdkVersion 19
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile project(':comtaxibulgariamap_mapsforge_044201406271417533')
compile files('libs/littlefluffylocationlibrary_r15.jar')
}
like image 731
NeoVe Avatar asked Feb 16 '15 17:02

NeoVe


People also ask

Is CompileOnly deprecated Gradle?

CompileOnly ( deprecated version — provided) Gradle adds the dependency to the compile classpath only ( that is it is not added to the build output). This is useful when you're creating an Android module and you need the dependency during compilation, but it's optional to have it present at runtime.

What is Gradle version in Android?

The current Gradle release is version 7.5.1, released on 05 Aug 2022. The distribution zip file comes in two flavors: Binary-only. Complete, with docs and sources.

Where is root build Gradle?

gradle file, located in the root project directory, defines build configurations that apply to all modules in your project. By default, the top-level build file uses the buildscript {} block to define the Gradle repositories and dependencies that are common to all modules in the project.


2 Answers

Your application module's build.gradle file should look like this.

apply plugin: 'com.android.application'

android {
   compileSdkVersion 17
   buildToolsVersion "21.1.2"

defaultConfig {
     applicationId "com.opentaxi.android"
     minSdkVersion 9
     targetSdkVersion 19
  }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {

    compile project(':comtaxibulgariamap_mapsforge_044201406271417533')
    compile fileTree(include: ['*.jar'], dir: 'libs')
}

And remove these lines from your main build.gradle (in application's root) if it exists as you posted.

  ext {
      compileSdkVersion 17
      buildToolsVersion '18.1.0'
    }
    dependencies {
    }
like image 109
Mohit Avatar answered Sep 24 '22 21:09

Mohit


Did you recently upgrade to Android Studio 1.0? If so, replace runProguard with minifyEnabled in your app/build.gradle.

like image 35
Bill Mote Avatar answered Sep 20 '22 21:09

Bill Mote