【问题标题】:Gradle DSL method not found: exclude()未找到 Gradle DSL 方法:exclude()
【发布时间】:2017-07-14 19:23:04
【问题描述】:

我在我的项目中使用了很多库。还有一些库使用相同的 jar 文件,因此我在 build.gradle 上写了这个:

dependencies {
compile fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.twotoasters.jazzylistview:library:1.2.1'
compile 'com.google.firebase:firebase-core:10.2.4'
compile 'com.google.firebase:firebase-database:10.2.4'
compile 'com.orhanobut:dialogplus:1.11@aar'
compile 'com.github.recruit-lifestyle:FloatingView:2.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.nineoldandroids:library:2.4.0'
compile ('com.specyci:residemenu:1.6+'){
    exclude group: 'com.nineoldandroids', module: 'library'    }
compile files('libs/poppyview.jar'){
    exclude group: 'com.nineoldandroids', module: 'library'    }

}

我收到错误: 错误:(54, 0) Gradle DSL 方法未找到: 'exclude()' 可能的原因:

  • “DopingEng”项目可能正在使用不包含该方法的 Android Gradle 插件版本(例如,在 1.1.0 中添加了“testCompile”)。 将插件升级到 2.3.1 版本并同步项目
  • “DopingEng”项目可能正在使用不包含该方法的 Gradle 版本。 打开 Gradle 包装文件
  • 构建文件可能缺少 Gradle 插件。 应用 Gradle 插件
  • Gradle 已经更新了,怎么解决这个问题?

    【问题讨论】:

    • 你应用了哪些插件?

    标签: java android android-studio gradle


    【解决方案1】:

    问题来了

    compile files('libs/poppyview.jar'){
       exclude ... 
    } 
    

    基于文件的依赖项与来自存储库的依赖项的工作方式不同。没有与之关联的元数据(例如,没有依赖信息),因此也没有什么可以排除的(因为没有传递依赖)。

    你有libs/poppyview.jar 的 pom/ivy 元数据吗?如果是这样,那么您不应该这样声明它(我建议使用本地 maven 存储库文件夹)。如果你不这样做,那么没有什么可以排除的

    【讨论】:

    • 如果我这样做:' compile 'com.specyci:residemenu:1.6+' compile files('libs/poppyview.jar') ' 我收到错误 Error:Execution failed for task ':app :transformClassesWithJarMergingForDebug'。 > com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/nineoldandroids/animation/Animator$AnimatorListener.class
    • 我必须写排除,如果我不应该这样,我该怎么办?
    • 正如我所说,files(...) 依赖没有传递依赖,所以没有什么可以排除的。副本要么包装在 poppyview.jar 内,要么来自其他地方
    • 那我该如何使用这个jar文件呢? @兰斯Java
    • 您可以在 build.gradle 中添加类似 this 的任务,以查看哪些 jar 包含重复的 com/nineoldandroids/animation/Animator$AnimatorListener.clas‌​s
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 2015-09-25
    • 2015-05-19
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多