【发布时间】:2015-06-01 21:12:44
【问题描述】:
我是 Android Studio 的新手,我使用 Eclipse 大约有 2 年了。我正在尝试理解这些解决方案。
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
Gradle DSL method not found: 'compile()'
我就是无法让它工作。
这就是它所说的......
错误:(17, 0) Gradle DSL 方法未找到:'compile()' 可能的原因:
和
'dependencies' 不能应用于'(groovy.lang.Closure)' less... (⌘F1) 此检查报告类型不兼容的分配
这是它给出错误的文件
// 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.+'
}
根据其他问题,您可能也需要这个。
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')
}
谁能帮我理解问题出在哪里,为什么会这样?
【问题讨论】:
-
从依赖项中移除应用插件。 (我不知道它做了什么,但它不是依赖)
-
好的...我删除了这个:应用插件:'android'
-
呃,试试这个:
apply plugin: 'announce' -
apply plugin: 'com.android.application' - 我可能错了,但这可能是应该存在的。它没有修复 compile() 错误所以我不知道..