找不到参数[{module = support-v4}]的方法exclude() [英] Could not find method exclude() for arguments [{module=support-v4}]
问题描述
我试图在关闭即时运行的情况下运行我的应用程序,但出现此错误:
I am trying to run my application with instant run turned off but I get this error:
错误:任务$的执行失败b $ b':app:transformClassesWithJarMergingForDebug'。
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException:java.util.zip。 ZipException:重复条目:
android / support / v4 / view / KeyEventCompatEclair.class
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/view/KeyEventCompatEclair.class
这是我的gradle文件:
Here is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.jua.app"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(path: ':app_Data')
compile files('libs/android-support-v4.jar')
}
我尝试过此线程:
compile files('libs/android-support-v4.jar'){
exclude module: "support-v4"
}
现在当我尝试立即同步gradle.build时,我收到此错误:
And now I am receiving this error when I try to Sync now gradle.build:
错误:(29,0)可以在类型为
的org.gradle.api类型的文件集合上,没有为参数
[{module = support-v4}]找到方法exclude()。 internal.file.collections.DefaultConfigurableFileCollection。
打开文件
Error:(29, 0) Could not find method exclude() for arguments [{module=support-v4}] on file collection of type org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection. Open File
我现在有点迷失了,如果有人有解决方法,我将不胜感激。
I am a little lost right now, If anyone has any idea how to solve this I would appreciate it.
编辑
我删除了
编译文件('libs / android-support-v4.jar')
compile files('libs/android-support-v4.jar')
完全完成,但我仍然遇到第一个错误。
completly and I still get the first error.
推荐答案
这是一个语法问题。您在其中调用exclude的闭包被解释为files()方法的参数,这是不正确的。应该看起来像这样
This is a syntax issue. The closure in which you are calling exclude is being interpreted as an argument to the files() method, which is incorrect. Should look like this
compile (files('libs/android-support-v4.jar')){
exclude module: "support-v4"
}
这篇关于找不到参数[{module = support-v4}]的方法exclude()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!