由于 Eclipse 中的 Java 堆空间,使用小型 android 应用程序无法执行 dex
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16412302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to execute dex because of java heap space in eclipse with a tiny android application
提问by Zach
I have an android application that only has one jar import which is 4 mb in size (Symja https://code.google.com/p/symja/) Literally the only code in the project is creating a new textview and setting it as the content view. But I am getting the error(s):
我有一个 android 应用程序,它只有一个大小为 4 mb 的 jar 导入(Symja https://code.google.com/p/symja/)从字面上看,项目中唯一的代码是创建一个新的 textview 并将其设置为内容视图。但我收到错误:
Conversion to Dalvik format failed: Unable to execute dex: Java heap space
Unable to execute dex: Java heap space
I have another android project which is alot bigger, almost 20,000 lines of code and it runs in seconds. My eclipse.ini has the following settings:
我有另一个 android 项目,它要大得多,几乎有 20,000 行代码,它在几秒钟内运行。我的 eclipse.ini 有以下设置:
-Dosgi.requiredJavaVersion=1.5
-XX:MaxPermSize=512m
-Xms512m
-Xmx1024m
I do not know why I cannot run this project. So any suggestions are greatly appreciated!
我不知道为什么我不能运行这个项目。所以任何建议都非常感谢!
Thanks.
谢谢。
采纳答案by Vera
I read, that symja library needs Java version 1.6. But your Eclipse uses Java 1.5. Maybe, it's a problem.
我读到,symja 库需要Java 版本 1.6。但是您的 Eclipse 使用 Java 1.5。也许,这是一个问题。
回答by Mihir Shah
Try the following:
请尝试以下操作:
Right click your project. Go to Properties -> Java Build Path -> Order and Export.
Uncheck the check box against your included library. Press OK and run the project.
On doing this Eclipse will take only the classes which are needed in the code, from the jar instead of storing all the classes from the jar.
在执行此操作时,Eclipse 将仅从 jar 中获取代码中需要的类,而不是存储 jar 中的所有类。
回答by akash
Modify the -XmsAm and -XmxBm paremeters in eclipse.ini so that they are large enough. The default is -Xms40m -Xmx384m. Try changing them both to -Xms512m -Xmx512m and restart eclipse to see if that helps. If not, continue to increase the values and restart eclipse until either one of two things happens:
修改 eclipse.ini 中的 -XmsAm 和 -XmxBm 参数,使它们足够大。默认值为 -Xms40m -Xmx384m。尝试将它们都更改为 -Xms512m -Xmx512m 并重新启动 eclipse 以查看是否有帮助。如果没有,继续增加值并重新启动 eclipse,直到发生以下两种情况之一:
Your build completes. Eclipse won't restart because you don't have enough memory. eclipse.ini is located at /etc/eclipse.ini in Ubuntu (assuming you installed Eclipse from the Ubuntu repositories).
您的构建完成。Eclipse 不会重新启动,因为您没有足够的内存。eclipse.ini 位于 Ubuntu 中的 /etc/eclipse.ini(假设您从 Ubuntu 存储库安装了 Eclipse)。