Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute dex because of java heap space in eclipse with a tiny android application

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):

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:

-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.

like image 341
Zach Avatar asked May 07 '13 06:05

Zach


People also ask

How do I fix Java heap space in Eclipse?

Temporary fix – Increase the heap size On the Eclipse menu, clicks Run -> Run Configurations.. , select the Java application we want to run, click on the Arguments tab, VM arguments section, and adjust a better Java initial maximum heap size.

How do I increase the heap size available to Eclipse?

Since Eclipse is a Java program, you can increase the heap size of Eclipse by using JVM memory options -Xms and -Xmx. There are two ways to provide JVM options to eclipse either updating the Eclipse shortcut or adding -vmargs on eclipse. ini file.


2 Answers

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.

like image 131
Mihir Shah Avatar answered Sep 20 '22 12:09

Mihir Shah


I read, that symja library needs Java version 1.6. But your Eclipse uses Java 1.5. Maybe, it's a problem.

like image 22
Vera Avatar answered Sep 20 '22 12:09

Vera