51

I got an extremely annyoing error in Eclipse (in the console):

Invalid layout of java.lang.String at value

A fatal error has been detected by the Java Runtime Environment:

Internal Error (javaClasses.cpp:129), pid=15238, tid=140306591237888
fatal error: Invalid layout of preloaded class

 JRE version: 7.0_07-b10
 Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode linux-amd64 compressed ops)
 Failed to write core dump. Core dumps have been disabled. To enable core dumping, try ulimit -c unlimited" before starting Java again

 An error report file with more information is saved as:
 /home/till/workspace/Encrypt/hs_err_pid15238.log

 If you would like to submit a bug report, please visit:
   http://bugreport.sun.com/bugreport/crash.jsp

Log Download

I cant't make any sense of this, because even Eclipse doesn't display any errors (in the code editor)... This is a real productivity-killer, because it blocks all progress. If anyone has any ideas on how to solve this, please answer this question.

Thank you really much in advance,

Till

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
tilpner
  • 4,351
  • 2
  • 22
  • 45
  • when u got this error? u said Eclipse didn't show any error, so was it pop-up when u trying to deploy it on your devices? – dumbfingers Oct 23 '12 at 12:11
  • 2
    It appears in the console, eclipse doesn't compile anything. With "no errors" I mean "no red signs next to a class". – tilpner Oct 23 '12 at 12:13
  • Not sure: might be some broken class file ("invalid layout of preloaded class"). – ignis Nov 03 '12 at 14:36
  • possible duplicate of [Internal Error (javaClasses.cpp:129)](http://stackoverflow.com/questions/12273118/internal-error-javaclasses-cpp129) – Raedwald Sep 04 '13 at 07:08
  • This happended for me if I ran a JUnit test from an Android project. Unchecking "Android Lib" from "Bootstrap Entries" helped. – Bohumir Zamecnik Apr 07 '14 at 08:22

7 Answers7

118

In case of an Android project, you have to remove Android Lib from the launch configuration for that specific class. Use the "walkthrough" below as a guide.

  • Project->Properties->Run/Debug Settings;
  • Select your Class and click "Edit";
  • Open the tab "Classpath" and remove Android Lib from "Bootstrap Entries";
  • Apply everything and Run the class again.
yprez
  • 14,854
  • 11
  • 55
  • 70
Odyr Sohn
  • 1,181
  • 2
  • 6
  • 2
  • I removed "Android 4.1.2" from the bootstrap entries, but afterwards it won't start, no error, no deployment on my nexus... On clicking "restore default entries" it reenables the "Android 4.1.2" lib, and then I get the very same error again. – tilpner Nov 03 '12 at 18:48
  • @StackOverflowException I had the same problem on my Eclipse. I removed the Android Lib from bootstrap entries and added the standard JRE library as a replacement. My problem was in a JUnit test, this solved the issue. – Ignazio Oct 26 '13 at 15:32
  • 4
    **Clearly** this is what `Invalid layout of preloaded class` means to say! I should have known. (Android, I love you but this is why we can't have nice things.) – Cheezmeister May 08 '14 at 23:26
  • This worked for me and enabled JUnit execution without selecting "Android JUnit Test" which fires up the emulator too even if you want to test non-UI components. But, I prefer to access this screen from Run > Run Configurations... > JUnit instead. – Ravi K Thapliyal Apr 06 '15 at 13:35
66

I had same problem,then(as Jeff Schultz said here) I tried:

Run As -> Android Application

and problem solved.But I don't know the reason that causes this problem.I hope this help you!

Community
  • 1
  • 1
hasanghaforian
  • 13,858
  • 11
  • 76
  • 167
  • Superb !!!! Thanx so much! It was caused in my case that I tried to run 1 file in my project as a regular Java file (with main etc). Since then it kept on dumping. Running (again) as an Android Application ... it works as normal! – tm1701 Jul 10 '15 at 07:34
4

This happened to me after:

  1. Inserting a class in the Android Application project where I had forgotten to remove public static void main(String args[]) function. (Had previously performed a quick test of the class).
  2. Tried to run the Application while I had opened and focused the above class on Eclipse editor.

The funny thing was that, after the Eclipse error, no matter on what class I switched the focus on, when I was trying to run the application again, I was stuck with the same error.

Inspired by Odyr Sohn solution, I managed to solve the problem (from Project->Properties->Run/Debug Settings deleting the faulty Launch configuration), but as soon as I was trying to run the application from this class, the same thing was happening again. When I removed public static void main(String args[]) function from the class, the problem was solved for good.

Community
  • 1
  • 1
TasDiam
  • 677
  • 8
  • 11
1

You should make a run configuration for an "Android application". If you make it for "Java Application" by mistake this error will show.

0

Same thing happened to me. I created a TestActivity and I guess it had a public static void main(String args[]) function. I went into the properties and then the Run/Debug and deleted TestActivity and it worked just fine.

UFGator
  • 55
  • 7
0

I had a similar problem on the fatal error: Invalid layout of preloaded class with Kepler Service Release 1 using windows 7.

Project -> Properties -> Java Build Path -> Order and Export --> check mark any 
unchecked library or Android version and then hit OK. Then run as Android application.
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
Seattle Ninja
  • 348
  • 2
  • 9
0

I had the same problem, solved it by:

Run->Run Configurations;

Click on left on "Android Application"-> Button on top "New";

then type in a name and "Browse" the Project -> works!

Markus
  • 21
  • 3