3

I am so tired of this java heap space error on my eclipse whenever I build my android application. I add 9 libraries to my android application. (Right click on project name -> Properties -> Android -> Add library).

In some forums, I find people asking to make changes in eclipse.ini file and some saying to add user library and add jars to it. And add user library to my app.

I have changed my MaxPermSize to 1024 in eclipse.ini. It didnt help

When I add user library to my app, my app is not able to recognise app_compat_v7.jar. It throws error on styles file where I use Theme.Appcompat.Light

May I know where I am going wrong ? Any help will be appreciated.

3
  • 1
    Have run into that error several times, and unchecking Project > Build Automatically followed by manually building it (and then signing the app, where the error usually occurs for me) did the trick. As for the style errors, try going to Show View > Problems, highlight the X's for the styles file only, and then delete the problems, followed by cleaning the project. Any time I change the styles.xml file it throws the same issues based on it not recognizing the compatibility/normal packages, but ends up running fine. Commented Apr 21, 2014 at 20:12
  • did u got any idea .How to fix this issue ?? Commented Aug 18, 2014 at 11:13
  • 1
    See this at the bottom of your eclipse prntscr.com/4e90ox In the screenshot given, the max heap space allocated is 211M and 118M has been used. I made changes to eclipse.ini file which looks like this prntscr.com/4e92de Commented Aug 19, 2014 at 5:48

1 Answer 1

4

Try the following:

Right click your project. Go to Properties -> Java Build Path -> Order and Export.

And

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.

And also see this question.

Second Technique

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:

  1. Your build completes.
  2. 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).

For MAC please see:

Finding eclipse.ini is a wee bit tricky. To locate it, right-click on the Eclipse Application icon and select "Show Package Contents", then double-click on the "Contents" folder and then double-click on the "MacOS" folder, the home of eclipse.ini

Sign up to request clarification or add additional context in comments.

7 Comments

I am trying to use Google-play-service-lib in my project when I check checkbox from Properties -> Java Build Path ->Order and Export I am getting error "unable to execute dex java heap space java heap space in eclipse"and if I unchecked and added .jar files of google play services libs I am getting an error "java.lang.NoClassDefFoundError:Lcom/google/android/gms/common/GooglePlayServicesUtil;" what to do? please help me I am trying to fix this error last 2 days. Also, change setting of eclipse.ini :( but not luck
Mohini , Keep increasing the Xms and Xmx values until it either works or you run out of physical memory. and first try by removing all associated libraries and jar. and then restart eclipse and reset it from start.
I set values -Xms4096M -Xmx4096M still getting problem. And If I am removing all associated libraries and jar project getting errors
Have you restart after saving in eclipse.ini
yes I restarted -Dosgi.requiredJavaVersion=1.6 --launcher.XXMaxPermSize 4096M -XX:MaxPermSize=4096M -Xms4096M -Xmx4096M
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.