Android的工作室无法解决错误“:应用程序:preDexDebug”应用程序、错误、工作室、Android

由网友(刪滁式誋憶)分享简介:我只是移动从Eclipse来吓人Android的工作室,并有摆脱烦恼,这似乎是一个相当普遍的错误。I'm just moving on from Eclipse to the intimidating Android Studio and have trouble getting rid of, what appea...

我只是移动从Eclipse来吓人Android的工作室,并有摆脱烦恼,这似乎是一个相当普遍的错误。

I'm just moving on from Eclipse to the intimidating Android Studio and have trouble getting rid of, what appears to be a fairly common error.

Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 1

我找遍了,并尝试了各种解决方案,包括从简单的重新启动我的工作室,和无效化清除缓存,除去JAR文件,并试图再次添加它们,但至今没有任何工程。我很新的这IDE,所以我什至不知道它如何工作以及构建文件应该看起来像。

I looked all over and have tried various solutions ranging from simply restarting my Studio, Invalidating and clearing the cache, removing the JARs and trying to add them again, but so far nothing works. I'm very new to this IDE so I'm not even sure how it works and what the build files are supposed to look like.

下面是我目前build.gradle(模块:应用程序)

Here's my current build.gradle (Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.culami"
        minSdkVersion 21
        targetSdkVersion 21
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_7
            targetCompatibility JavaVersion.VERSION_1_7
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:support-v4:21.0.3'
    compile files('libs/WebSocket.jar')
    compile files('libs/android-support-v13.jar')
    compile files('libs/json-org.jar')
    compile files('libs/socketio.jar')
}

该项目从Eclipse的进口,这样​​做的原因是,我面临的JSON-org.jar和WebSocket.jar一些制造问题。我没能解决这一问题,并在issue仍然是开放的。我不知道如何通过摇篮添加这些依赖关系,因为GitHub的页面并没有真正说如何。

The project was imported from Eclipse and the reason for doing so was that I was facing some build issues with json-org.jar and WebSocket.jar. I wasn't able to fix this and the issue is still open. I'm not sure how do add these dependencies via gradle because the github page doesn't really say how.

下面是一个从摇篮控制台输出。

Here's the output from the Gradle console.

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library 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
AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;","position":{},"original":"com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","position":{},"original":"tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","position":{},"original":"tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","position":{},"original":"tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","position":{},"original":"tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","position":{},"original":"tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","position":{},"original":"tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.command.dexer.Main.run(Main.java:246)","position":{},"original":"tat com.android.dx.command.dexer.Main.run(Main.java:246)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.command.dexer.Main.main(Main.java:215)","position":{},"original":"tat com.android.dx.command.dexer.Main.main(Main.java:215)"}
AGPBI: {"kind":"SIMPLE","text":"tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"tat 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.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 2

* 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: 23.247 secs

在如何解决这一问题preDexDebug错误将是一个很大的帮助任何帮助!作为一个方面说明,我也没能看到我的'库'文件夹在左边的工程资源管理器。

Any help on how to fix this preDexDebug error will be a great help! As a side note, I'm also not able to see my 'libs' folder in the project explorer on the left.

推荐答案

你有一个jar文件或一个lib出现多次,并需要与配置,在你的gradle.build工作

you have a jar file or a lib appearing multiple times and need to work with "configuration" in your "gradle.build"

寻找如何分析依赖关系是这样的:

look for how to analyze dependencies with something like:

./gradlew :app:dependencies

background在包装

./gradlew --info clean assembleDebug > ../myProj_build

会给你一个构建文件额外的信息,您可以分析在您的preDex的错误信息

will give you extra info in a build file that you can analyze for details on your "preDex" errors

阅读全文

相关推荐

最新文章