Andrea Richiardi
Andrea Richiardi

Reputation: 733

Robolectric asm NoSuchMethodError, classpath issue?

After pulling the new changes (2.3-SNAPSHOT), all my app tests fail with the same result. The code fails when instanciating TestClass and precisely when the getConstructors() method is (reflectively) called. The exception raised is:

java.lang.NoSuchMethodError: org.objectweb.asm.MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V at org.objectweb.asm.commons.GeneratorAdapter.invokeInsn(Unknown Source) at org.objectweb.asm.commons.GeneratorAdapter.invokeVirtual(Unknown Source) at org.robolectric.bytecode.AsmInstrumentingClassLoader$ClassInstrumentor.instrumentConstructor(AsmInstrumentingClassLoader.java:541) at org.robolectric.bytecode.AsmInstrumentingClassLoader$ClassInstrumentor.instrument(AsmInstrumentingClassLoader.java:422) at org.robolectric.bytecode.AsmInstrumentingClassLoader.getInstrumentedBytes(AsmInstrumentingClassLoader.java:245) at org.robolectric.bytecode.AsmInstrumentingClassLoader.findClass(AsmInstrumentingClassLoader.java:159) at org.robolectric.bytecode.AsmInstrumentingClassLoader.loadClass(AsmInstrumentingClassLoader.java:98) at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493) at java.lang.Class.getConstructors(Class.java:1517) at org.junit.runners.model.TestClass.<init>(TestClass.java:39) at org.junit.runners.ParentRunner.<init>(ParentRunner.java:75) at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57) at org.robolectric.RobolectricTestRunner$HelperTestRunner.<init>(RobolectricTestRunner.java:649) at org.robolectric.RobolectricTestRunner.getHelperTestRunner(RobolectricTestRunner.java:289) at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:206) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) [CUT]

I am running inside Intellij IDEA and my .iml correctly shows:

<orderEntry type="library" exported="" name="asm-5.0.1" level="project" />

Moreover, if I debug to the asm library, I do see:

public void visitMethodInsn(int i, java.lang.String s, java.lang.String s1, java.lang.String s2, boolean b) { /* compiled code */ }

I don't really know if it's related with Robolectric because all the standard tests pass when I do mvn clean install...what can be the problem?

Upvotes: 0

Views: 943

Answers (1)

Snicolas
Snicolas

Reputation: 38168

I got the same error. It looks like there is a conflicting version of asm somewhere in your classpath, probably asm 4.x where it should be asm 5. Also, take care that asm comes in 2 forms : asm-all which contains all the classes of asm and asm, asm-utils, asm-tree, etc, that are split packages. This can also create conflicts.

Upvotes: 1

Related Questions