我尝试同步项目时遇到以下构建错误:
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
Run Code Online (Sandbox Code Playgroud)
我已经尝试将他们链接到我的每一个gradle插件应用到底部的那个链接,但同样的问题,所以我得出结论,第一个错误是原因.
这是AlexTest的build.gradle文件(项目目录):
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()
}
} …Run Code Online (Sandbox Code Playgroud) 

要向Android studio添加V4支持库,我按照以下文档:https://developer.android.com/tools/support-library/setup.html#libs-without-res但是我收到错误.这就是我做的
//顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
dependencies {
compile "com.android.support:support-v4:18.0.+"
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我得到一个弹出窗口,建议我同步gradle.当我同步Gradle时,我收到此错误:
错误:(20,0)未找到Gradle DSL方法:'compile()'可能的原因:
我错过了任何一步吗?请建议.
的build.gradle(APP)
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.appt.shreyabisht.staymax"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
} …Run Code Online (Sandbox Code Playgroud) 在El Capitan上使用Android Studio 2.0,如下一个屏幕截图所示:

我发现了一个无法报告的错误:在我的项目中添加片段后,AS搞砸了我的模块build.gradle文件.我的意思是,在添加片段之前,他们的文件看起来像这个截图:

我可以手动修复它,但每次添加片段时它都很烦人.无论如何要解决它吗?
我和El Capitan在Mac OX上.
android android-studio build.gradle android-gradle-plugin osx-elcapitan
我将在Android Studio中浏览Google的"将Google Play服务添加到您的项目"文档:https: //developer.android.com/google/play-services/setup.html
我正在使用该文档来修改新创建的Android项目的build.gradle文件.在第2步(将Google Play服务添加到您的项目中)中,它指出:
添加此行:
apply plugin: 'android'
Run Code Online (Sandbox Code Playgroud)
在依赖项下,添加以下内容:
compile 'com.google.android.gms:play-services:5.0.77'
Run Code Online (Sandbox Code Playgroud)
它还表示在更新Google Play服务后更新该版本,根据Android SDK Manager,该服务目前为18.
这是我在顶层的整个build.gradle文件(此文件的父文件是根文件夹).
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'android'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
compile 'com.google.android.gms:play-services:18'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
保存后,它会提示同步.我同步它,但得到:
Build script error, …Run Code Online (Sandbox Code Playgroud) 我需要将 android.support.v4.widget.NestedScrollView 添加到我的项目中,根据这个问题,这需要 V4 支持库。在答案中说。。。
您需要在依赖项中添加这一行:
编译'com.android.support:support-v4:23.4.0'
...我假设引用了 build.gradle 文件。我有两个 - 一个顶级的和一个模块的。只有我的顶级有一个依赖关键字,所以我把它放在那里。但是当我这样做的时候我得到了
错误:(8, 0) 未找到 Gradle DSL 方法:“compile()”
...这个问题在这里 以及这个问题中都得到了解决,它表明我需要将其移动到我的模块的 build.gradle 中。但模块 build.gradle 有一个完全不同的结构,所以我不知道它去了哪里。
我的顶级 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:2.1.2'
compile 'com.android.support:support-v4:23.4.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Run Code Online (Sandbox Code Playgroud)
我的模块级看起来像这样:
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.assemblyguide.remote" …Run Code Online (Sandbox Code Playgroud) 几个小时以来我一直在研究以下问题,但还没有找到解决问题的方法.我已经尝试了Stack Overflow中的以下修复(Android Studio更新到1.0会破坏Gradle插件v0.13.1之后的MultiDex和重复Zip条目),但它们都没有工作.
我在尝试构建程序时遇到以下错误:
Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: org/apache/commons/io/CopyUtils.class
Run Code Online (Sandbox Code Playgroud)
该错误似乎表明commons-io在构建过程中被包含两次
我正在使用Android Studio和Gradle来包含多个Robospice依赖项.这是我的Gradle构建文件的依赖项部分:
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-v4:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile'com.google.api-client:google-api-client-android:1.19.0'
// You must install or update the Google Repository through the SDK manager to use this dependency.
// The Google Repository (separate from the corresponding library) can be found in the Extras category.
//compile 'com.google.android.gms:play-services:4.3.23'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.jakewharton:butterknife:${butterknifeVersion}"
compile 'com.sun.jersey:jersey-bundle:1.8'
compile 'com.google.code.gson:gson:2.3'
compile 'org.codehaus.jackson:jackson-core-asl:1.9.0' …Run Code Online (Sandbox Code Playgroud) 我正在尝试将新模块添加到我的应用程序中.我成功添加了movie-api模块(你可以在下面的图片中看到),但是当我尝试添加另一个模块(客户端应用程序)时,我收到错误,如图所示.

我尝试了不同的解决方案,包括没有找到的Gradle DSL方法:'compile()',但是对我来说不起作用.感谢您的帮助!
Build.gradle文件:
buildscript {
ext {
springBootVersion = '1.4.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
jar {
baseName = 'client-app'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
Run Code Online (Sandbox Code Playgroud)