我有这个gradle错误.
错误:(9,0)未找到Gradle DSL方法:'compile()'
我试过引用类似的问题,但它没有用.
Android gradle build错误:(9,0)未找到Gradle DSL方法:'compile()'.
在同步Build.Gradle时出现错误"未找到Gradle DSL方法:'compile()'"
发现不支持的Gradle DSL方法:'compile()'!
我的build.gradle
代码在这里
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:6.5.+'
// 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.gradle(Module.app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.example.simplemaker.pushtest"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes …
Run Code Online (Sandbox Code Playgroud) 我一直在使用Gradle Android插件v0.12,但我决定升级到新版本,因为我需要新的功能(并且改进的速度总是一个加号).
在更新到新的v0.13.1之后,我继续获得"重复Zip输入"(来自Proguard),而之前一切正常.完整的错误:
java.io.IOException:无法写[/Users/.../classes-proguard/netherlands/release/classes.jar](无法读取[/Users/.../.gradle/caches/modules- 2/files-2.1/org.apache.commons/commons-io/1.3.2/b6dde38349ba9bb5e6ea6320531eae969985dae5/commons-io-1.3.2.jar(;;;;;;!META-INF/MANIFEST.MF)](重复zip条目[commons-io-1.3.2.jar:org/apache/commons/io/CopyUtils.class]))(之前的CopyUtils是FileUtils).
我正在使用以下包装选项:packagingOptions
{
exclude 'AndroidManifest.xml'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/MANIFEST.MF'
exclude '!META-INF/MANIFEST.MF'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
Run Code Online (Sandbox Code Playgroud)
你可以告诉我,我正在排除清单文件......
只是为了测试它,我改回了版本0.12.0并且一切都再次工作,回到0.13.*它打破了(但我需要0.13.*)!
此外,我正在使用以下库:
有人也遇到过这个问题吗?如果是这样,任何人都可以帮助我(现在已经在这个问题上打了两天头脑!)?谢谢!
我正在尝试构建和维护一个旧的应用程序,但我无法通过构建阶段.在我的app/build.gradle
文件中我有
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.apache.commons:commons-io:1.3.2'
//some more libraries compiled as well
}
Run Code Online (Sandbox Code Playgroud)
但在尝试执行时遇到以下错误:
错误:任务':myApp'的执行失败.com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:org/apache/commons/io/CopyUtils.class
这几乎可以肯定是因为当我编译那个jar时,在我的外部库树的顶部,生成了这个:
为什么会发生这种情况,如何让它停止以便我可以完成构建?
当我尝试在我的nexus 7上运行应用程序时,gradle构建每次都会失败并给出相同的错误:
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
org/apache/commons/io/CopyUtils.class
Run Code Online (Sandbox Code Playgroud)
该错误似乎表明CopyUtils.class
from commons-io
在构建过程中被包含两次.
完整日志:
Information:Gradle tasks [:android:assembleDebug]
:android:preBuild UP-TO-DATE
:android:preDebugBuild UP-TO-DATE
:android:checkDebugManifest
:android:preReleaseBuild UP-TO-DATE
:android:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:android:prepareDebugDependencies
:android:compileDebugAidl UP-TO-DATE
:android:compileDebugRenderscript UP-TO-DATE
:android:generateDebugBuildConfig UP-TO-DATE
:android:mergeDebugShaders UP-TO-DATE
:android:compileDebugShaders UP-TO-DATE
:android:generateDebugAssets UP-TO-DATE
:android:mergeDebugAssets UP-TO-DATE
:android:generateDebugResValues UP-TO-DATE
:android:generateDebugResources UP-TO-DATE
:android:mergeDebugResources UP-TO-DATE
:android:processDebugManifest UP-TO-DATE
:android:processDebugResources UP-TO-DATE
:android:generateDebugSources UP-TO-DATE
:android:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:android:compileDebugJavaWithJavac UP-TO-DATE
:android:compileDebugNdk UP-TO-DATE
:android:compileDebugSources UP-TO-DATE
:android:prePackageMarkerForDebug
:android:transformClassesWithJarMergingForDebug FAILED
Error:Execution failed for task
':android:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException:
java.util.zip.ZipException: duplicate entry:
org/apache/commons/io/CopyUtils.class
Information:BUILD FAILED
Information:Total time: 11.208 …
Run Code Online (Sandbox Code Playgroud) 嗨有类似错误,如重复输入.
FAILURE:构建因异常而失败.
出了什么问题:任务'执行失败':电子书:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException:重复条目:android/support/annotation/AttrRes.class
尝试:使用--stacktrace选项运行以获取堆栈跟踪.使用--info或--debug选项运行以获取更多日志输出.
建筑失败
总时间:1分钟46.13秒
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':ui-reader')
compile "com.android.support:support-v4:23.1.1"
compile "com.android.support:support-v13:20.0.0"
compile files('libs/Flurry_3.2.1.jar')
}
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
lintOptions {
abortOnError false
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// …
Run Code Online (Sandbox Code Playgroud)