zoukankan      html  css  js  c++  java
  • Android gradle用exclude排除引用包中的dependency引用

    项目突然编译不通过,报如下错误

        FAILURE: Build failed with an exception.
         
        * What went wrong:
        Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
        > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug104.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug115.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug93.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug39.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug12.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug21.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug47.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug4.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug5.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug22.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug14.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug30.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug31.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug13.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug48.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug10.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug19.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug49.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug6.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug23.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug11.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug41.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug24.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug7.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug34.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug17.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug26.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug42.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug51.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug25.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug43.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug8.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug52.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug27.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug44.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug18.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug35.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug9.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug45.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug28.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug15.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug1.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug2.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug32.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug46.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug16.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug29.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug3.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug50.jar, D:wsAutosizingTestappuildintermediates ransformsdexBuilderdebug20.jar
          Program type already present: android.support.v4.widget.SlidingPaneLayout$AccessibilityDelegate
          Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
         
        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
         
        * Get more help at https://help.gradle.org
         
        BUILD FAILED in 19s

    经排查发现原来是项目中引用的第三方包'liji.library.dev:citypickerview:4.1.1'中引用的v7包和项目引用的v7包冲突导致的。

    可以直接删除项目的v7包引用,直接用第三包里面的v7包就可以了。

    但是如果第三方包引用的包太老旧,你执意要用最新的,那该怎么办呢?你可以用exclude把第三方包里的指定dependency排除掉,然后再重新编译就可以成功了。

        dependencies {
            implementation 'com.android.support:appcompat-v7:28.0.0'
            implementation ('liji.library.dev:citypickerview:4.1.1') {
                exclude group: 'com.android.support'
            }
        }

  • 相关阅读:
    Java多态
    推荐TED演讲:20岁光阴不再来(Why 30 is not the new 20)
    HDU 5305 Friends (DFS)
    C#高级编程八十一天----捕获异常
    Amazon EC2安装mysql多实例并配置主从复制
    python coding style guide 的高速落地实践
    Tomcat 在win7/win8 系统下tomcat-users.xml.new(拒绝访问)解决方法
    jsp+oracle实现数据库内容以表格形式在前台显示(包含分页)
    JSP/SERVLET入门教程--Servlet 使用入门
    解决系统打开CHM文件无法正常显示
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/11856031.html
Copyright © 2011-2022 走看看