找不到Gradle DSL方法:'compile'

时间:2016-03-12 09:55:11

标签: android gradle

当我同步gradle文件时,它显示错误:

Error:(26, 0) Gradle DSL method not found: 'ompile()'

可能的原因:

  • 项目'Athletto'可能正在使用不包含该方法的Gradle版本。 打开Gradle包装器文件
  • 构建文件可能缺少Gradle插件。 申请Gradle插件
  • 我搜索了各种解决方案,但没有一个工作。我不知道我必须使用哪个插件。这是我的gradle文件:

    build.gradle(Module):

                apply plugin: 'com.android.application'
    
            android {
                compileSdkVersion 23
                buildToolsVersion "23.0.2"
    
                defaultConfig {
                    applicationId "com.example.hp.athletto"
                    minSdkVersion 16
                    targetSdkVersion 16
                    multiDexEnabled=true
                    versionCode 1
                    versionName "1.0"
                }
                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:23.1.1'
                ompile 'com.android.support:design:23.0.1'
                compile 'com.github.vajro:MaterialDesignLibrary:1.6'
                compile 'com.android.support:cardview-v7:23.2.0'
                compile('com.github.afollestad.material-dialogs:commons:0.8.5.6@aar') {
                    transitive = true
                }
            }
    

    build.gradle(Project):

                // 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:2.1.0-alpha1'
                }
            }
    
            allprojects {
                repositories {
                    jcenter()
                    mavenCentral()
                }
            }
    

    1 个答案:

    答案 0 :(得分:1)

    您遇到了输入错误:在第3行依赖关系中将ompile更改为compile 'com.android.support:design:23.0.1'

    dependencies {
                compile fileTree(dir: 'libs', include: ['*.jar'])
                compile 'com.android.support:appcompat-v7:23.1.1'
                ompile 'com.android.support:design:23.0.1'//<--error here
                compile 'com.github.vajro:MaterialDesignLibrary:1.6'
                compile 'com.android.support:cardview-v7:23.2.0'
                compile('com.github.afollestad.material-dialogs:commons:0.8.5.6@aar') {
                    transitive = true
                }
            }