19

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

4 Answers 4

16

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 {
    }
0
9

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

3
  • 1
    On my app/build.gradle there's no runProguard, but "minifyEnabled false" instead
    – NeoVe
    Commented Feb 16, 2015 at 18:16
  • Oh, and "proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'" any ideas?
    – NeoVe
    Commented Feb 16, 2015 at 18:16
  • That won't cause any issues. Can you post your app/build.gradle? That's likely the one with the problem.
    – Bill Mote
    Commented Feb 16, 2015 at 18:28
3

worked for me after I added, in build.gradle (Module):

apply plugin: 'kotlin-kapt'

1

Can also get this error if one puts implementation file in the wrong gradle.

Should be put inside build.graddle (module) here

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

rather than in build.graddle(App)

Not the answer you're looking for? Browse other questions tagged or ask your own question.