繁体   English   中英

Gradle错误:任务':app:dexDebug'的执行失败。

[英]Gradle Error:Execution failed for task ':app:dexDebug'.

请我尝试在我的设备上运行一个简单的登录和注册应用程序。 java和xml文件都很好,但是当我运行它时,出现了gradle错误。 我遵循的教程没有使用gradle系统。 它已包含在清单文件中:

<uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="21" />

这可能是原因吗?

摇篮:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.example.stephen.logintest"
        minSdkVersion 11
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
}

错误信息:

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42211Library 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
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
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)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 30.608 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException:
Multiple dex files define Landroid/support/annotation/AnimRes;

当您使用具有不同版本的相同库时,会发生这种问题。

在您的情况下,请检查您的libs文件夹中是否有某些库正在使用支持注释库。 在您的依赖性中,您正在使用appcompat v21.1.1 ,该版本使用支持注释v.21.1.1

另外。对于此问题,这并不重要。

您不需要在清单中使用它。

<uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="21" />

这些值被gradle覆盖,在其中您使用了不同的值:

 defaultConfig {
        minSdkVersion 11
        targetSdkVersion 22
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM