Android的工作室RuntimeException的:在DEX写线程意外的异常 [英] Android Studios RuntimeException: Unexpected exception in dex writer thread

查看:2151
本文介绍了Android的工作室RuntimeException的:在DEX写线程意外的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经越来越此奇怪的错误,整个今天的 - 任何人都知道是怎么回事错在这里。

据我所知,我一直正确地使用multidex库(以下是从app.gradle文件):

  defaultConfig {
    的applicationIDcom.example.simon
    14的minSdkVersion
    targetSdkVersion 23
    版本code 1
    的versionName1.0
    / *启用multidex * /
    multiDexEnabled真
}依赖{
    / *启用multidex * /
    编译com.android.support:multidex:1.0.1
}

我的顶层文件的gradle是非常基本的:

  buildscript {
    库{
        jcenter()
    }
    依赖{
        类路径'com.android.tools.build:gradle:1.3.0
        类路径'com.google.gms:谷歌服务:1.3.1
        //注意:不要在这里把你的应用程序依赖关系;他们属于
        //在单个模块的build.gradle文件
    }
}allprojects {
    库{
        jcenter()
    }
}

错误:

 执行任务:[:应用:generateDebugSources,
:应用:generateDebugAndroidTestSources]与按需配置并行执行是一个孵化
特征。
:应用程序:preBuild UP-TO-DATE
:应用程序:preDebugBuild UP-TO-DATE
:应用:checkDebugManifest
:应用程序:preReleaseBuild UP-TO-DATE
:应用程序:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:应用程序:prepareComAndroidSupportPaletteV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:应用程序:prepareComDigitsSdkAndroidDigits162Library UP-TO-DATE
:应用程序:prepareComFacebookAndroidFacebookAndroidSdk440Library UP-TO-DATE
:应用程序:prepareComFacebookConcealConceal101Library UP-TO-DATE
:应用程序:prepareComGithubCurioustechizenAndroidAgoLibrary130Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:应用程序:prepareComTheartofdevEdmodoAndroidImageCropper104Library UP-TO-DATE
:应用程序:prepareComTwitterSdkAndroidTweetComposer080Library UP-TO-DATE
:应用程序:prepareComTwitterSdkAndroidTweetUi131Library UP-TO-DATE
:应用程序:prepareComTwitterSdkAndroidTwitter161Library UP-TO-DATE
:应用程序:prepareComTwitterSdkAndroidTwitterCore141Library UP-TO-DATE
:应用程序:prepareIoFabricSdkAndroidFabric134Library UP-TO-DATE
:应用程序:prepareDebugDependencies
:应用:compileDebugAidl UP-TO-DATE
:应用:compileDebugRenderscript UP-TO-DATE
:应用:generateDebugBuildConfig UP-TO-DATE
:应用:generateDebugAssets UP-TO-DATE
:应用:mergeDebugAssets UP-TO-DATE
:应用:generateDebugResValues​​ UP-TO-DATE
:应用:processDebugGoogleServices
:应用:generateDebugResources
:应用:mergeDebugResources UP-TO-DATE
:应用:processDebugManifest UP-TO-DATE
:应用:fabricGenerateResourcesDebug
:应用:processDebugResources
:应用:generateDebugSources
:应用程序:preDebugAndroidTestBuild UP-TO-DATE
:应用程序:prepareDebugAndroidTestDependencies
:应用:compileDebugAndroidTestAidl UP-TO-DATE
:应用:processDebugAndroidTestManifest UP-TO-DATE
:应用:compileDebugAndroidTestRenderscript UP-TO-DATE
:应用:generateDebugAndroidTestBuildConfig UP-TO-DATE
:应用:generateDebugAndroidTestAssets UP-TO-DATE
:应用:mergeDebugAndroidTestAssets UP-TO-DATE
:应用:generateDebugAndroidTestResValues​​ UP-TO-DATE
:应用:generateDebugAndroidTestResources UP-TO-DATE
:应用:mergeDebugAndroidTestResources UP-TO-DATE
:应用:processDebugAndroidTestResources UP-TO-DATE
:应用:generateDebugAndroidTestSources UP-TO-DATEBUILD SUCCESSFUL总时间:3.913秒执行任务:[:应用:assembleDebug]与按需配置并行执行是一个孵化
特征。
:应用程序:preBuild UP-TO-DATE
:应用程序:preDebugBuild UP-TO-DATE
:应用:checkDebugManifest
:应用程序:preReleaseBuild UP-TO-DATE
:应用程序:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:应用程序:prepareComAndroidSupportPaletteV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:应用程序:prepareComDigitsSdkAndroidDigits162Library UP-TO-DATE
:应用程序:prepareComFacebookAndroidFacebookAndroidSdk440Library UP-TO-DATE
:应用程序:prepareComGithubCurioustechizenAndroidAgoLibrary130Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:应用程序:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:应用程序:prepareComTheartofdevEdmodoAndroidImageCropper104Library
:应用程序:prepareDebugDependencies
:应用:compileDebugAidl UP-TO-DATE
:应用:compileDebugRenderscript UP-TO-DATE
:应用:generateDebugBuildConfig UP-TO-DATE
:应用:generateDebugAssets UP-TO-DATE
:应用:mergeDebugAssets UP-TO-DATE
:应用:generateDebugResValues​​ UP-TO-DATE
:应用:processDebugGoogleServices
:应用:generateDebugResources
:应用:mergeDebugResources UP-TO-DATE
:应用:processDebugManifest UP-TO-DATE
:应用:fabricGenerateResourcesDebug
:应用:processDebugResources
:应用:generateDebugSources
:应用:processDebugJavaRes UP-TO-DATE
:应用:compileDebugJavaWithJavac UP-TO-DATE
:应用:compileDebugNdk UP-TO-DATE
:应用:compileDebugSources UP-TO-DATE
:应用:collectDebugMultiDexComponents UP-TO-DATE
:应用:packageAllDebugClassesForMultiDex UP-TO-DATE
:应用:shrinkDebugMultiDexComponents UP-TO-DATE
:应用:createDebugMainDexClassList UP-TO-DATE
:应用:dexDebugExecuting
任务:[:应用:assembleDebug]与按需配置并行执行是一个孵化
特征。
:应用程序:preBuild UP-TO-DATE
:应用程序:preDebugBuild UP-TO-DATE
:应用:checkDebugManifest
:应用程序:preReleaseBuild UP-TO-DATE
:应用程序:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:应用程序:prepareComAndroidSupportPaletteV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:应用程序:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:应用程序:prepareComDigitsSdkAndroidDigits162Library UP-TO-DATE
:应用程序:prepareDebugDependencies
:应用:compileDebugAidl UP-TO-DATE
:应用:compileDebugRenderscript UP-TO-DATE
:应用:generateDebugBuildConfig UP-TO-DATE
:应用:generateDebugAssets UP-TO-DATE
:应用:mergeDebugAssets UP-TO-DATE
:应用:generateDebugResValues​​ UP-TO-DATE
:应用:processDebugGoogleServices
:应用:generateDebugResources
:应用:mergeDebugResources UP-TO-DATE
:应用:processDebugManifest UP-TO-DATE
:应用:fabricGenerateResourcesDebug
:应用:processDebugResources
:应用:generateDebugSources
:应用:processDebugJavaRes UP-TO-DATE
:应用:compileDebugJavaWithJavac UP-TO-DATE
:应用:compileDebugNdk UP-TO-DATE
:应用:compileDebugSources UP-TO-DATE
:应用:collectDebugMultiDexComponents UP-TO-DATE
:应用:packageAllDebugClassesForMultiDex UP-TO-DATE
:应用:shrinkDebugMultiDexComponents UP-TO-DATE
:应用:createDebugMainDexClassList UP-TO-DATE
:应用:dexDebug AGPBI:
{种:简单,文:意外的顶级
例外:,源:[{}]} AGPBI:
{种:简单,文:了java.lang.RuntimeException:意外
例外DEX作家线程,源:[{}]} AGPBI:
{种:简单,文:\\达
com.android.dx.command.dexer.Main.runMultiDex(Main.java:397),源:[{}]}
AGPBI:{种:简单,文:\\达
com.android.dx.command.dexer.Main.run(Main.java:275),源:[{}]}
AGPBI:{种:简单,文:\\达
com.android.dx.command.dexer.Main.main(Main.java:245),源:[{}]}
AGPBI:{种:简单,文:\\达
com.android.dx.command.Main.main(Main.java:106),源:[{}]}
 失败故障:建立失败,一个例外。*出了什么问题:执行失败的任务:应用程序:dexDebug。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程命令
C:\\ Program Files文件\\的Java \\ jdk1.7.0_76 \\斌\\ java.exe的''与完成
非零值2*尝试:用--stacktrace选项获取堆栈跟踪运行。与--info或--debug选项来运行,以获得更多的日志输出。构建失败总时间:1分钟5.426秒


解决方案

谷歌上搜索了一阵之后,我发现这个问题是没有足够的堆被分配到DEX作家。

我通过把在我的应用程序gradle.build以下固定它

  dexOptions {
    真正的增量
    javaMaxHeapSize4G
}

这个选项还设法显著加快的gradle我构建。

<一个href=\"http://stackoverflow.com/questions/25006075/extremely-long-build-with-gradle-android-studio\">Extremely很长的构建与摇篮(Android的一室公寓)

I have been getting this strange error the whole of today - anyone know what is going wrong here?

As far as I know, I have been using the multidex library correctly (the below is from the app.gradle file):

defaultConfig {
    applicationId "com.example.simon"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    /*Enabling multidex*/
    multiDexEnabled true
}

dependencies {
    /*    Enabling multidex*/
    compile 'com.android.support:multidex:1.0.1'
}

My top level gradle file is very basic:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.google.gms:google-services:1.3.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Error:

    Executing tasks: [:app:generateDebugSources,
:app:generateDebugAndroidTestSources]

Parallel execution with configuration on demand is an incubating
feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportPaletteV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComDigitsSdkAndroidDigits162Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk440Library UP-TO-DATE
:app:prepareComFacebookConcealConceal101Library UP-TO-DATE
:app:prepareComGithubCurioustechizenAndroidAgoLibrary130Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:app:prepareComTheartofdevEdmodoAndroidImageCropper104Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTweetComposer080Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTweetUi131Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTwitter161Library UP-TO-DATE
:app:prepareComTwitterSdkAndroidTwitterCore141Library UP-TO-DATE
:app:prepareIoFabricSdkAndroidFabric134Library 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:processDebugGoogleServices
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDebug
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE

BUILD SUCCESSFUL

Total time: 3.913 secs Executing tasks: [:app:assembleDebug]

Parallel execution with configuration on demand is an incubating
feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportPaletteV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComDigitsSdkAndroidDigits162Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk440Library UP-TO-DATE
:app:prepareComGithubCurioustechizenAndroidAgoLibrary130Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation780Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps780Library UP-TO-DATE
:app:prepareComTheartofdevEdmodoAndroidImageCropper104Library
: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:processDebugGoogleServices
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDebug
:app:processDebugResources
:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:packageAllDebugClassesForMultiDex UP-TO-DATE
:app:shrinkDebugMultiDexComponents UP-TO-DATE
:app:createDebugMainDexClassList UP-TO-DATE
:app:dexDebugExecuting
tasks: [:app:assembleDebug]

Parallel execution with configuration on demand is an incubating
feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2301Library UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportPaletteV72301Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72301Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42301Library UP-TO-DATE
:app:prepareComDigitsSdkAndroidDigits162Library 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:processDebugGoogleServices
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDebug
:app:processDebugResources
:app:generateDebugSources
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:packageAllDebugClassesForMultiDex UP-TO-DATE
:app:shrinkDebugMultiDexComponents UP-TO-DATE
:app:createDebugMainDexClassList UP-TO-DATE
:app:dexDebug AGPBI:
{"kind":"simple","text":"UNEXPECTED TOP-LEVEL
EXCEPTION:","sources":[{}]} AGPBI:
{"kind":"simple","text":"java.lang.RuntimeException: Unexpected
exception in dex writer thread","sources":[{}]} AGPBI:
{"kind":"simple","text":"\tat
com.android.dx.command.dexer.Main.runMultiDex(Main.java:397)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat
com.android.dx.command.dexer.Main.run(Main.java:275)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat
com.android.dx.command.dexer.Main.main(Main.java:245)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat
com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}


 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
'C:\Program Files\Java\jdk1.7.0_76\bin\java.exe'' 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: 1 mins 5.426 secs

解决方案

After googling for a while, I found the problem was that not enough heap was allocated to the dex writer.

I fixed it by putting in the following in my app gradle.build:

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

This option also managed to speed up my gradle build significantly.

Extremely long build with Gradle (Android Studio)

这篇关于Android的工作室RuntimeException的:在DEX写线程意外的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆