android studio \ Java \ jdk1.8.0_65 \ bin \ java.exe'中的错误以非零退出值2结束

时间:2015-12-12 15:51:44

标签: java android eclipse

你好我在尝试运行我的应用程序时遇到错误这是一个曾经工作的应用程序(虽然它是在eclipse中)一直试图让它在android工作室中运行几次错误之后现在这个打了我,并且无法弄清楚任何事情。谢谢你的帮助。

编辑 当我尝试运行应用程序时构建应用程序时没有错误。

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:502)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
    at com.android.dx.command.dexer.Main.run(Main.java:277)
    at com.android.dx.command.dexer.Main.main(Main.java:245)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_65\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED

的build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
    }
}
apply plugin: 'android'

dependencies {
    compile "com.android.support:support-v4:23.1.1"
compile 'com.android.support:appcompat-v7:23.1.1'
compile fileTree(dir: 'libs', include: '*.jar')
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    useLibrary 'org.apache.http.legacy'

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

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

2 个答案:

答案 0 :(得分:1)

按照this answer的建议删除android_support_annotations.jar文件。您的问题是由Android支持库中默认包含的注释jar引起的,因此现在有两个副本。

您还可以尝试暂时从build.gradle中删除compile "com.android.support:support-v4:18.0.+",看看是否会产生影响。

(解决方案是删除依赖项中除compile 'com.android.support:appcompat-v7:23.1.1'之外的所有内容。)

答案 1 :(得分:0)

如此基本地删除每个编译部分后,它只有这个左边

dependencies {
compile 'com.android.support:appcompat-v7:23.1.1'

}

将依赖变为此