未找到Gradel DSL方法' android()'错误android工作室

时间:2015-12-04 10:51:27

标签: android android-studio gradle android-gradle build.gradle

我是Android工作室的新手。

添加lib文件后,我发现找不到classl DSL方法错误

应用程序/ build.gradel

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

android {
    compileSdkVersion 19
    buildToolsVersion '23.0.1'
}
dependencies {
}
apply plugin: 'checkstyle'

下面是我得到错误的代码build.gradel代码。

   apply plugin: 'com.android.library'

android {
    compileSdkVersion 17
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 10
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles 'proguard-android-optimize.txt'
        }
    }
}

dependencies {
    compile files('libs/core.jar')
}

有两个build.gradel,一个是app,另一个是库。

enter image description here

1 个答案:

答案 0 :(得分:1)

您使用的是错误的build.gradle文件

顶级文件中,您无法使用 android块:

只需从第一个build.gradle

中删除此部分即可
android {
    compileSdkVersion 19
    buildToolsVersion '23.0.1'
}
dependencies {

}
apply plugin: 'checkstyle'