Android Studio V1.0.2,错误:(2,0)找不到Gradle DSL方法:'compile()'?

时间:2015-02-12 08:27:15

标签: macos compilation gradle

在Mac上使用gradle 1.0.0的Android Studio 1.0.2

当我开始一个新项目时,gradle项目同步失败并出现错误:

Error:(2, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'My Application' 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>

项目下的build.gradle

// 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'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

在应用下构建.gradle

dependencies {
    compile 'com.android.support:appcompat-v7:21.+'
}
apply plugin: 'com.android.application' android {
    compileSdkVersion 21 buildToolsVersion "21.1.1" defaultConfig {
        applicationId "com.macernow.djstava.myapplication" minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionName "1.0"
    } buildTypes {
        release {
            minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
} dependencies {
    compile 'com.android.support:appcompat-v7:21.+' compile fileTree(dir: 'libs', include: ['*.jar'])
}

我也尝试在线/离线gradle设置,错误仍然存​​在。请帮助我,谢谢。

1 个答案:

答案 0 :(得分:0)

通过

彻底卸载Android Studio

&#13;
&#13;
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
&#13;
&#13;
&#13;

然后重新安装,一切正常。