如何删除通过添加的gradle重复图书馆? [英] How to Remove Duplicate Libraries added via gradle?

查看:507
本文介绍了如何删除通过添加的gradle重复图书馆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用两个库。一种是,另一个是的这个

每当我运行的应用程序与编辑的测试库它显示的意外顶级EXCEPTION

 错误:执行失败的任务:手机:dexDebug。
> com.android.ide.common.internal.LoggedErrorException:无法运行命令:
    E:\\ Android的\\我\\我\\ SDK \\构建工具\\ 21.1.2 \\ dx.bat --dex --no-优化--output C:\\项目\\ RemoteiT \\ RemoteiT \\手机\\编译\\中间体\\ DEX \\调试--input列表= C:\\项目\\ RemoteiT \\ RemoteiT \\手机\\编译\\中间体\\ tmp目录\\ DEX \\调试\\ inputList.txt
错误code:
    2
输出:
    意外的顶级例外:
    com.android.dex.DexException:多DEX文件定义LCOM / nineoldandroids /动画/动画$ AnimatorListener;
        在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        在com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        在com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        在com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        在com.android.dx.command.dexer.Main.run(Main.java:246)
        在com.android.dx.command.dexer.Main.main(Main.java:215)
        在com.android.dx.command.Main.main(Main.java:106)

我假设上述错误显示com.nineoldandroids添加两次或冲突。

所以我试图在的build.gradle文件中删除。但它仍然显示错误!

是我的假设是正确的?要不然哪里我会错呢?

的build.gradle

 应用插件:'com.android.application安卓{
    compileSdkVersion 21
    buildToolsVersion21.1.2    defaultConfig {
        的applicationIDme.aruhan.remt
        14的minSdkVersion
        targetSdkVersion 21
        版本code 1
        的versionName1.0
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
}配置{
    //避免支持库包含双
    所有* .exclude组:com.nineoldandroids',模块:'materialDesign
}依赖{
    编译com.android.support:appcompat-v7:21.0.0
    编制项目(':materialDesign')
    编译com.rengwuxian.materialedittext:库:1.7.1
}


解决方案

而不是在配置添加它的。我添加了排除只有这样的库。

 编译('com.rengwuxian.materialedittext:库:1.7.1'){
        排除组:com.nineoldandroids',模块:图书馆
    }

I am using two libraries in my project. One is this and the other is this.

Whenever i run the App with Edit Test library it shows UNEXPECTED TOP-LEVEL EXCEPTION

Error:Execution failed for task ':mobile:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    E:\Android\me\me\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\dex\debug --input-list=C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
        at com.android.dx.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)

I Assume that the above Error shows that com.nineoldandroids is added twice or conflicting.

So i tried to remove it in the build.gradle file. But it is still showing the Error!

Is my Assumption is right? or else where did i go wrong ?

Build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "me.aruhan.remt"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

configurations {
    // to avoid double inclusion of support libraries
    all*.exclude group: 'com.nineoldandroids', module: 'materialDesign'
}

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile project(':materialDesign')
    compile 'com.rengwuxian.materialedittext:library:1.7.1'
}

解决方案

Instead of adding it in the Configurations. I added the exclude for only the library like this.

compile ('com.rengwuxian.materialedittext:library:1.7.1') {
        exclude group: 'com.nineoldandroids', module: 'library'
    }  

这篇关于如何删除通过添加的gradle重复图书馆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆