我收到下面的生成错误,当我尝试同步我的项目:
错误:(9,0)没有找到摇篮DSL的方法:编译()
可能的原因:该项目的AlexTest'可以是使用一个版本的摇篮不包含的方法。
构建文件可能丢失一个摇篮插件。
链接:应用摇篮插件
我试图将每一个摇篮插件他们联系我在该链路上的底部,但同样的问题,所以我的结论是第一个错误是原因。
下面是AlexTest(项目目录)的build.gradle文件:
buildscript {
库{
jcenter()
}
依赖{
类路径com.android.tools.build:gradle:0.13.2
编译com.google.android.gms:播放服务:6.1.11
//注意:不要在这里放置应用程序依赖;他们属于
//在单个模块build.gradle文件
}
}
allprojects {
库{
jcenter()
}
}
我觉得这是它在和麻烦摇篮文件。但我不知道它指的是什么方法。
另外这里是它也提到了gradle-wrapper.properties:
#Mon 11月10日1时06分十二秒的PST 2014
distributionBase = GRADLE_USER_HOME
distributionPath =包装/ dists中
zipStoreBase = GRADLE_USER_HOME
zipStorePath =包装/ dists中
distributionUrl = HTTPS \://services.gradle.org/distributions/gradle-2.1-all.zip
也许是摇篮版本中distributionUrl需要匹配所述一个在依赖
我也有在app目录本身build.gradle文件 - 1水平低,但我不认为这是它指的是,但在这里它是:
应用插件:com.android.application
安卓{
compileSdkVersion 20
buildToolsVersion21.1.1
defaultConfig {
的applicationIDcom.snappiesticker.alextest
的minSdkVersion 16
targetSdkVersion 20
版本code 1
VERSIONNAME1.0
}
buildTypes {
推出 {
runProguard假
proguardFiles getDefaultProguardFile('ProGuard的-android.txt'),'proguard-rules.pro
}
}
}
依赖{
编译文件树(导演:库,包括:['的* .jar'])
编译com.google.android.gms:播放服务:6.1 +。
}
解决方案
我试图将每一个摇篮插件他们联系我在该链路上的底部,但同样的问题,所以我的结论是第一个错误是原因。
正确的。
下面是AlexTest(项目目录)的build.gradle文件:
您会注意到,该文件包含一个code注释:
//注意:不要在这里放置应用程序依赖;他们属于
//在单个模块build.gradle文件
从该文件行
删除编译6.1.11 com.google.android.gms:玩-服务。离开
编译com.google.android.gms:播放服务:6.1 +
,你必须在其他 build.gradle
文件。
在依赖
封在 buildscript
是摇篮的插件而已。顶级依赖
关闭,在模块的 build.gradle
文件中发现,对于应用程序的依赖关系。
I am getting the following build error when I try and sync my project:
Error:(9, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'AlexTest' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
link: Apply Gradle plugin
I have tried applying every single gradle plugin they link me to in that link on the bottom, yet same issue, so I conclude that the first error is the cause.
Here is the build.gradle file for AlexTest (the project directory):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
compile 'com.google.android.gms:play-services:6.1.11'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I think that was the gradle file it was having trouble with. But I'm not sure what method it is referring to.
Also here is the gradle-wrapper.properties which it also referred to:
#Mon Nov 10 01:06:12 PST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip
perhaps the gradle version in the distributionUrl needs to match the one in the dependency?
I also have a build.gradle file in the app directory itself - 1 level lower, though I don't think that is what it was referring to, but here it is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.snappiesticker.alextest"
minSdkVersion 16
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.1.+'
}
解决方案
I have tried applying every single gradle plugin they link me to in that link on the bottom, yet same issue, so I conclude that the first error is the cause.
Correct.
Here is the build.gradle file for AlexTest (the project directory):
You will notice that this file contains a code comment:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Remove the compile 'com.google.android.gms:play-services:6.1.11'
line from that file. Leave the compile 'com.google.android.gms:play-services:6.1.+'
that you have in the other build.gradle
file.
The dependencies
closure in buildscript
is for Gradle plugins only. The top-level dependencies
closure, found in the module's build.gradle
file, is for application dependencies.