找不到Android Gradle方法:'compile()'

时间:2017-04-09 15:13:18

标签: android android-gradle build.gradle

由于以下gradle错误,无法运行Android应用程序。

Gradle DSL method not found : 'compile()'
Possible Causes :
              The project XXXX may be using a version of Gradle that does not contain the method .

The build file may be missing a Gradle Plugin . 

请帮助解决此问题。

编辑:

文件build.gradle

PFB我的build.gradle文件来自项目,大多数文件似乎是在依赖项中添加,但为什么问题无法解决相同问题。

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "xxxxxxxx"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 2
        versionName "1.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

android {
    useLibrary 'org.apache.http.legacy'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'me.zhanghai.android.materialprogressbar:library:1.1.6'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.sa90.materialarcmenu:library:1.4.1'
    compile files('libs/jxl.jar')
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.github.clans:fab:1.6.4'
    compile 'com.android.support:cardview-v7:23.4.0'
    compile files('libs/acra-4.6.1.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.1@aar') {
        transitive = true;
    }
    compile 'commons-codec:commons-codec:1.10'
    compile "com.android.support:support-v4:+"
    compile 'com.squareup.picasso:picasso:2.3.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.daimajia.slider:library:1.1.5@aar'
}

1 个答案:

答案 0 :(得分:0)

您在项目build.gradle中有依赖关系,请确保将其放在app / build.gradle中。

例如在app / build.gradle中

dependencies {
    compile 'com.android.support:appcompat-v7:25.2.0'
}