无法构建。任务':app:dexDebug'的执行失败。

时间:2015-03-19 12:15:23

标签: android build android-gradle build.gradle

我的项目只有一个lib,但是我没有构建它。

来自https://github.com/dinocore1/DevsmartLib-Android/tree/master/devsmartlib

lib。

非常感谢任何帮助。

请告诉我是否需要更多信息。

devsmartlib> gradle.build (我自己写这篇文章是因为我找不到回购邮件中的任何内容)

apply plugin: 'com.android.library'

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

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

myapp>的build.gradle

 apply plugin: 'com.android.application'

    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.hs.mybookapp"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 2
        versionName "1.1 Beta"
    }
    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:21.0.3'
    compile project(":devsmartlib")
}

Root build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Gradle Console

 Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild
:app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:devsmartlib:compileLint
:devsmartlib:copyReleaseLint UP-TO-DATE
:devsmartlib:preBuild
:devsmartlib:preReleaseBuild
:devsmartlib:checkReleaseManifest
:devsmartlib:preDebugBuild
:devsmartlib:preDebugTestBuild
:devsmartlib:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:devsmartlib:prepareReleaseDependencies
:devsmartlib:compileReleaseAidl UP-TO-DATE
:devsmartlib:compileReleaseRenderscript UP-TO-DATE
:devsmartlib:generateReleaseBuildConfig UP-TO-DATE
:devsmartlib:generateReleaseAssets UP-TO-DATE
:devsmartlib:mergeReleaseAssets UP-TO-DATE
:devsmartlib:generateReleaseResValues UP-TO-DATE
:devsmartlib:generateReleaseResources UP-TO-DATE
:devsmartlib:mergeReleaseResources UP-TO-DATE
:devsmartlib:processReleaseManifest UP-TO-DATE
:devsmartlib:processReleaseResources UP-TO-DATE
:devsmartlib:generateReleaseSources UP-TO-DATE
:devsmartlib:compileReleaseJava UP-TO-DATE
:devsmartlib:extractReleaseAnnotations UP-TO-DATE
:devsmartlib:mergeReleaseProguardFiles UP-TO-DATE
:devsmartlib:processReleaseJavaRes UP-TO-DATE
:devsmartlib:packageReleaseJar UP-TO-DATE
:devsmartlib:compileReleaseNdk UP-TO-DATE
:devsmartlib:packageReleaseJniLibs UP-TO-DATE
:devsmartlib:packageReleaseLocalJar UP-TO-DATE
:devsmartlib:packageReleaseRenderscript UP-TO-DATE
:devsmartlib:packageReleaseResources UP-TO-DATE
:devsmartlib:bundleRelease UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:app:prepareMyBookAppDevsmartlibUnspecifiedLibrary 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 UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
    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)


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\HS\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\HS\AndroidStudioProjects\MyBookApp\app\build\intermediates\dex\debug --input-list=C:\Users\HS\AndroidStudioProjects\MyBookApp\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
        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)



* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 9.638 secs

1 个答案:

答案 0 :(得分:0)

我现在才意识到我使用的lib包含此文件android-support-v4.jar。删除此文件将解决问题。