1

I'm new to Android Studio, I've been using Eclipse for about 2 years. I've trying understanding these solutions.

Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.

Gradle DSL method not found: 'compile()'

I just can't get it to work.

Here's what it says..

Error:(17, 0) Gradle DSL method not found: 'compile()' Possible causes:

  • The project 'clxxxii - PMv5' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • and

    'dependencies' cannot be applied to '(groovy.lang.Closure)' less... (⌘F1) This inspection reports assignments with incompatible types

    Here's the file where it's giving an error

    // 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:1.1.0'    }
    }
    
    allprojects {
        repositories {
            mavenCentral()
        }
    }
    dependencies {
        apply plugin: 'announce'
        compile 'com.android.support:appcompat-v7:21.0.0'
        compile 'com.android.support:cardview-v7:21.0.+'
    }
    

    And based on the other questions, you may need this too.

    apply plugin: 'android'
    
    android {
        compileSdkVersion 17
        buildToolsVersion "19.0.3"
    
        defaultConfig {
            minSdkVersion 8
            targetSdkVersion 19
        }
    
        buildTypes {
            release {
                runProguard false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            }
        }
    }
    
    dependencies {
        compile 'com.android.support:support-v4:+'
        compile files('libs/FlurryAnalytics_3.3.0.jar')
        compile files('libs/heyzap-ads-sdk.jar')
        compile files('libs/HomeBaseSDK2.2.jar')
        compile files('libs/placed-persistent-sdk-1.10.jar')
        compile files('libs/revmob-6.7.0.jar')
    }
    

    Can someone help me understand what the problem is, and why it's happening?

    Community
    • 1
    • 1
    losethequit
    • 203
    • 3
    • 17

    1 Answers1

    1

    This might not fully answer your question but maybe you can get your project running. These dependencies dont belong in your first build.gradle file :

    dependencies {
    apply plugin: 'announce'
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    }
    

    Your dependencies in your Project build.gradle should look like this, the comment is generated by the IDE and tells you not to put your app dependencies here :

     dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    Move them to the /app/build.gradle file, and I modified your file a little so its up to date to the currently newest version of buildTools etc. You might have to download some of them from your SDK Manager if you dont already have :

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"
    
    defaultConfig {
        applicationId "your.package.name"
        minSdkVersion 8
        targetSdkVersion 22
    }
    
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
       }
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.0.0'
        compile 'com.android.support:support-v4:+'
        compile files('libs/FlurryAnalytics_3.3.0.jar')
        compile files('libs/heyzap-ads-sdk.jar')
        compile files('libs/HomeBaseSDK2.2.jar')
        compile files('libs/placed-persistent-sdk-1.10.jar')
        compile files('libs/revmob-6.7.0.jar')
     }
    
    A Honey Bustard
    • 3,433
    • 2
    • 22
    • 38
    • @ now i'm getting this error.. /Users/clxxxii/Downloads/l'espace de travail/clxxxii - PMv5/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-v11/values.xml with a lot of missing resources.. i.e.: Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'. – losethequit Mar 28 '15 at 17:26
    • Or maybe you need to set your minSdk version higher I would recommend setminSdk to 12 or even 15 that targets most devices out there. – A Honey Bustard Mar 28 '15 at 17:35
    • yes finally, just like 20 seconds ago.. but I ironically imported the wrong version of the project.. – losethequit Mar 28 '15 at 18:04