1

I created Android test project and want to use JMOCK on it. I include following jars to my project classpath

  • amcrest-all-1.1.jar
  • jmock-2.5.1.jar
  • jmock-junit4-2.5.1.jar
  • junit.jar
  • objenesis-1.0.jar

until compiling i've got this error message :

[2012-07-06 17:14:40 - mockTest] Dx ...at bytecode offset 0000001b locals[0000]: Lorg/hamcrest/generator/qdox/parser/impl/JFlexLexer; locals[0001]: I locals[0002]: [C locals[0003]: [C locals[0004]: [I locals[0005]: [I locals[0006]: locals[0007]: locals[0008]: locals[0009]: locals[000a]: locals[000b]: locals[000c]: locals[000d]: locals[000e]: locals[000f]: locals[0010]: stack[top0]: [B ...while working on block 001b ...while working on method yylex:()I ...while processing yylex ()I ...while processing org/hamcrest/generator/qdox/parser/impl/JFlexLexer.class

[2012-07-06 17:14:40 - mockTest] Dx 1 error; aborting [2012-07-06 17:14:40 - mockTest] Conversion to Dalvik format failed with error 1

What is the problem? is there any incorrect jar in classpath?

Viktor Apoyan
  • 10,655
  • 22
  • 85
  • 147

2 Answers2

0

The problem is that JMock works using dynamic bytecode generation, but Dalvik isn't capable of doing that: dynamic bytecode generation is compiled down to JVM bytecode that's not supported by Dalvik; hence the error when converting.

Unfortunately, that means you can't use JMock on Android -- if you need it for testing, you'll have to run those tests on a JVM.

Andrew Aylett
  • 39,182
  • 5
  • 68
  • 95
0

It seem you have included JAR that have same package names? In Android Dependencies open all jar and ensure that every jar have Unique packages.

Mohsin Naeem
  • 12,542
  • 3
  • 39
  • 53
  • @M Mohsin Naeem At first i used instand of hamcrest-all-1.1.jar the hamcrest-core-1.1.jar and hamcrest-library-1.1.jar jars, but until compiling i got error from system it says that there are dublicate LICENSE.TXT files on those jars. Maybe the problem realy because of wrong merging this two jars. Then could you tell me from where i can get normaly working hamcrest-all-1.1.jar? – Viktor Apoyan Jul 06 '12 at 13:51