Gradle 错误 - 任务 ':app:dexDebug' 执行失败 [英] Gradle error - Execution failed for task ':app:dexDebug'

查看:41
本文介绍了Gradle 错误 - 任务 ':app:dexDebug' 执行失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 MPAndroidChartLibrary 添加到我的 Android Studio 项目中,但是当我尝试运行该应用程序时,它一直失败并出现 1 个错误.我对 gradle 不是很了解,所以我真的不知道出了什么问题.

I am trying to add the MPAndroidChartLibrary to my Android Studio project, however when I try to run the app, it keeps failing with 1 error. I am not very good with gradle, so I don't really know whats going wrong.

我的 gradle 文件是这样的:

My gradle file is this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.2"

    defaultConfig {
        applicationId "com.bacon.corey.audiotimeshift"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.android.support:support-v4:21.0.0'
    compile files('C:/Users/Corey/.AndroidStudioBeta/Projects/AudioTimeShift/libraries/mpandroidchartlibrary-1-7-4.jar')
}

据我所知,这应该没问题,但它不起作用.这是来自 Gradle 控制台的日志:

As far as I can see, this should all be fine, however it is not working. This is the log from the Gradle console:

:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42100Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava
Note: C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\src\main\java\com\bacon\corey\audiotimeshift\MainActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Program Files (x86)\Android\android-sdk\build-tools\21.0.2\dx.bat --dex --output C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\dex\debug C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\classes\debug C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\dependency-cache\debug C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\classes-08104da82547c1da8de562eb9350a514962ceaa7.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\classes-c916341f097aba848a3f8d1cb524d87b40a5e434.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\internal_impl-21.0.0-dd323fb38f6f05cc36bfccaf6824e44b4d16534e.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\library-2.4.0-1028d824e09b12c83da4be3e497c82fdc33874f5.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\mpandroidchartlibrary-1-7-4-1e0626ccaecee3e156334e8c3c9fcf07d352edb9.jar C:\Users\Corey\.AndroidStudioBeta\Projects\AudioTimeShift\app\build\intermediates\pre-dexed\debug\support-annotations-21.0.0-9528452d0a4563476596d64e06f21a3014c413f7.jar
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/ValueAnimator$AnimatorUpdateListener;
        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:302)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)
Information:BUILD FAILED
Information:Total time: 18.241 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

如果有人能给我一些关于我哪里出错的提示,我将不胜感激.

If someone could please give me a few pointers as to where I am going wrong, I would be immensively grateful.

谢谢,科里 B :)

推荐答案

MPAndroidChart 已经将 com.nineoldandroids:library:2.4.+ 作为依赖项.从您的依赖项中删除 compile 'com.nineoldandroids:library:2.4.0'.

MPAndroidChart already has com.nineoldandroids:library:2.4.+ as a dependency. Remove compile 'com.nineoldandroids:library:2.4.0' from your dependencies.

这篇关于Gradle 错误 - 任务 ':app:dexDebug' 执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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