Internal Error (javaClasses.cpp:129)

后端 未结 6 1871
北海茫月
北海茫月 2021-01-04 14:22

I\'m trying run a test with JUnit 4 and Robolectric on Eclipse but all time I receive this error:

Invalid layout of java.lang.String at value
#
# A fatal err         


        
相关标签:
6条回答
  • 2021-01-04 14:51

    You need to correct your run configuration.

    If you want to run an JUnit test with

    "right click on test class in the package explorer"->"Run As"->"JUnit Test"
    

    on an android project, you need to set the "Android JUnit Test Launcher" as launcher. You have do use that android launcher even if your launch configuration has the type "JUnit".

    You can find it under:

    "right click on test class in the package explorer"->"Properties"->"Run/Debug Settings"->"Edit..." 
    


    Example:

    Test:

    import junit.framework.TestCase;
    
    public class ExampleTest extends TestCase{
    public ExampleTest(String name){
        super(name);
    }
    
    protected void setUp() throws Exception{
        super.setUp();
    }
    
    protected void tearDown() throws Exception{
        super.tearDown();
    }
    
    public void testFoo(){
        fail("Not yet implemented");
    }
    

    }

    Create run configuration:

    "Run"->"Run Configurations..."->"Right click on JUnit"->"New"->"Set project and Test class"->"Select Android JUnit Test Launcher"->"Run"
    

    Notice: If you are using an x86 jdk you will get the following error if your Launcher is set to "Eclipse JUnit Launcher":

        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=3844, tid=4828
        #  fatal error: Invalid layout of preloaded class
        #
        # JRE version: 7.0_17-b02
        # Java VM: Java HotSpot(TM) Client VM (23.7-b01 mixed mode windows-x86 )
        # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
    
    0 讨论(0)
  • 2021-01-04 14:54

    For me was the solution: Run -> Run Configurations... -> at tab Test click Select Preferred Launcher and select Use configuration specific settings with selection Android JUnit Test Launcher.

    Delete all entries under JUnit (left column of Run Configurations dialog; RightMouse - Delete).

    Then Run as -> JUnit Test and optionally select Use configuration specific settings with Android JUnit Test Launcher.

    0 讨论(0)
  • 2021-01-04 15:08

    This may not be your issue but I was able to get past this by using the Run As -> Android Application.

    However, I'm not sure if you are using android or not. Possibly check the Run configuration for other issues.

    0 讨论(0)
  • 2021-01-04 15:12

    It goes easier. Got to Run->Configuration and look for JUnit and Android JUnit Tests. Delete your config if it is there. Then the next time you click on Run it will ask about the configuration. You choose first JUnit and then in the next dialog activate "Use configuration specific settings" and then choose Android JUnit Test Laucher.

    0 讨论(0)
  • 2021-01-04 15:14

    Same issue encountered to me as well and reason was I added main(String s[]) method in my android project.

    So just remove main(String s[]) method from project and run as Android Application.

    0 讨论(0)
  • 2021-01-04 15:16

    Right click java class with main, run configurations then go to classpath tab, remove the android library there. then run.

    I hope this helps.

    0 讨论(0)
提交回复
热议问题