zoukankan      html  css  js  c++  java
  • Android Studio Error -- Could not create the Java Virtual Machine

    :app:dexDebug
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    
     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:
        E:Program Filesadt-bundle-windows-x86-20140702sdkuild-tools21.1.2dx.bat --dex --no-optimize --output E:androidworkspaceDialogDemoappuildintermediatesdexdebug --input-list=E:androidworkspaceDialogDemoappuildintermediates	mpdexdebuginputList.txt
    Error Code:
        1
    Output:
        Error: Could not create the Java Virtual Machine.
        Error: A fatal exception has occurred. Program will exit.
    
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    BUILD FAILED

    Gradle打包的时候经常出现此错误,命令--stacktrace

    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.

    目前google and 百度查询有两种解决方案

    1.设置java的

    -Xms128m
    -Xmx512m
    -XX:MaxPermSize=250m

    修改这三个参数

    2.升级JDK

    经过测试2种方案都不行

    通过

    dx.bat --dex

    命令的dx.bat脚本有这样一句代码

    REM By default, give dx a max heap size of 1 gig and a stack size of 1meg.
    rem This can be overridden by using "-JXmx..." and "-JXss..." options below.
    set defaultXmx=-Xmx1024M
    set defaultXss=-Xss1m
    set defaultXmx=-Xmx1024M

    原因就是此处设置的Xmx为1024M,编译打包APK时java虚拟机内存空间不足,修改为512M即可正常编译打包了。

    set defaultXmx=-Xmx512M
  • 相关阅读:
    leetcode33. Search in Rotated Sorted Array
    pycharm 设置sublime text3 monokai主题
    django class Meta
    leetcode30, Substring With Concatenation Of All Words
    Sublime text3修改tab键为缩进为四个空格,
    sublime text3 python打开图像的问题
    安装上imesupport输入法依然不跟随的解决办法,
    sublime text3 的插件冲突弃用问题,
    sublime text3 BracketHighlighter括号匹配的设置
    windows 下wget的使用
  • 原文地址:https://www.cnblogs.com/fenglie/p/4208678.html
Copyright © 2011-2022 走看看