摇篮错误 - 执行失败的任务“:应用程序:dexDebug”摇篮、应用程序、错误、任务

2023-09-07 04:26:27 作者:、壹生心疼

我想给MPAndroidChartLibrary添加到我的Andr​​oid Studio项目,但是当我尝试运行应用程序,它不断用1个故障失败。我不是很好的摇篮,所以我真的不知道怎么回事错了。

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 dont really know whats going wrong.

我的摇篮文件是这样的:

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')
}

据我所看到的,这都应该是好的,但它不工作。 这是德日志从摇篮控制台:

As far as i can see, this should all be fine, however it is not working. This is teh 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

如果有人可以请给我一些指点到哪里我错了,我会immensivly感激。

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

谢谢,科里B:)

推荐答案

MPAndroidChart已经有 com.nineoldandroids:图书馆:2.4 + 作为一个依赖。删除编译。com.nineoldandroids:图书馆: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.